# Chapter 12 Exercises¶

1. Fix 3 syntax errors in the code below so that it correctly prints “x is less than 3” and then “All done” when x is less than 3.

2. The code currently prints “Hello” when the number is less than 3. Change it so that it prints “Hello” when the number is equal to 3.

3. Fix the indention in the code below to use a price of 1.45 if the weight is less than 1 and a price of 1.15 otherwise. There is also one syntax error.

4. Fill in line 1 with a weight that will make the total equal 1, and fix the indentation errors.

5. Fix 3 errors with indention in the code below to correctly set the price to 1.5 if the weight is less than 2 and otherwise set it to 1.3.

6. The code currently does not do anything if the number is equal to 2. Fix it so that it prints “Hey” if the number is 2.

7. Fix 4 errors in the code below to print “x is a number from 1 to 10” when x is greater than or equal to 1 and less than or equal to 10.

8. The following code prints “This is not 8” when the number is not 8. Change the if statement, so that it does the same thing but only uses one expression (No “and” or “or”).

9. Finish the conditional on line 3 to print “You can go out!” if either cleanedRoom or finishedHomework is true (not 0). It should always print “All done” as well.

10. Complete the conditional and fix the errors so that it prints “Good job” when the number is between 1 and 10 (inclusive) or is 15 and “Fail” when it is not.

11. Fix 5 errors in the following code to set the price to 1.45 if the weight is less than or equal to 1 and otherwise set it to 1.15.

12. Fix the indentation below, so that the code sets the price based off the weight, then checks if the total is greater than the amount in your wallet.

13. Change 3 lines in the code below to correctly set the grade so that a 90 and above is an A, 80-89 is a B, 70 - 79 is a C, 60-69 is a D and below 60 is an E.

14. Fix the errors in the code, and change it, so there’s only 1 if statement. The code should print “The number is 5” when the number is 5, and should print “The number is NOT 5” when it is not.

15. Fix 5 errors in the following code to set price to 1.45 if weight is less than 1 and otherwise set it to 1.15.

16. Complete and finish the code on lines 1 and 4 so that the code prints “Hi”.