1. Engineering
  2. Computer Science
  3. 20 pts read about the if and else statements in...

Question: 20 pts read about the if and else statements in...

Question details

(20 pts) Read about the if and else statements in Section 3.2, including what happens when the various programs in Section 3.2 are run. (If you want to run them yourself to see what happens, I strongly encourage that! And: it is ok to type them in and run them, even including the eval function calls; I dont want to scare you too much about that. The eval function is only risky when someone you dont trust is putting input into your code, e.g. when you are making a app that the general public will use.) Once you think you understand how if and else works, consider this code, which is incomplete. Add the code that is needed so that if the user puts in something other than CA for the state, the code will print Out of State Tuition. Be sure to indent your code properly, and include all needed punctuation homestate = input (Please enter your state: ) if homeStateCA print (In State Tuition) (10 pts) Section 3.2 discusses how to use the range function with a loop so that you can cause a variable to take on a sequence of values-the sample code illustrates this by printing those values. (Later well do other things with those sequences of values such as adding them, or multiplying them, or using them to index into a list or string, or to draw things.) In the space below, write a few lines of Python that uses a loop with the range function to print the values shown in the box at right. (Your answer must use a loop with range to get credit.)

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution