# Chapter 13 Exercises¶

1. Fix 7 problems in the code below so that it runs.

2. Fix the errors in the code so that it prints “Less than 5” when a number is less than 5 and “Greater than or equal to 5” when it is greater than or equal to 5.

3. Fix 6 errors in the code below so that it works correctly.

4. Complete the code to get user input, and make choices based off the input. The input should either be “in”, “left”, or “right”; make sure the user knows that.

5. Fix the code below to assign grades correctly using elif and else. You can assume the numbers are all correct.

6. The following code prints both statements, change it so that it only prints the first one when the age is less than 6.

7. Change the code below to use elif and else rather than several ifs. Also fix it to print “Good job!” if the score is greater than 10 and less than or equal to 20 and “Amazing” if the score is over 20.

8. Complete the code so that it iterates through the list of numbers and prints positive, negative, or neither based off the integer.

9. Change the code below to use elif and else.

10. Fix the errors in the code and change it to use elif’s and else so that if the user’s score is greater than the high score, it prints “Good job!”, if it’s lower, print “Try again.”, and if it’s the same print “You tied the high score”.

11. Change the following code to use elif and else instead.

12. Add statements to the code, so that if the user gives a number less than 5, you ask for the input again, and have another set of decision statements based off if the number is greater than, less than, or equal to 3.

13. Change the code below to use only 1 if, 1 elif, and 1 else.

14. Fix the code and change the statements so there are three sets of if and else and 2 elifs.

15. Change the code below into a procedure that takes a number as a parameter and prints the quartile. Be sure to test each quartile.

16. Fix the code so that it prints only 1 thing for each age group and uses elif and else.

17. Write a function that will take a number as input and return a fortune as a string. Ask the user to pick a number to get the fortune before you call the function. Have at least 5 different fortunes. Use if, elif, and else.