2.13. Chapter Exercises

== is an operator that checks for equality. If the value on the left side is equal to the value on the right side, it gives True. Otherwise it gives False.

Insert the correct operators in place of the #’s so each line prints True. Don’t change any of the numbers.

Add a set of parentheses to the expression x = 6 * 1 - 2 so that the code below prints -6 instead of 4.

Add parentheses to x = 12 * 2 - 3 + 4 * 2 so that it prints -4 instead of 29.

Complete the code on lines 3 and 5 below to print the cost of a car trip of 500 miles when the car gets 26 miles per gallon and gas costs 3.45 a gallon. It should print 66.34615384615385.

It is currently 10:00, complete the code to tell what time it is going to be in 18 hours (12-hour time, not 24-hour time). The answer should be 4 because 28 hours divided into 12 hour chunks leaves a remainder of 4 hours.

Hint: rember that **%* is the modulo or remainder operator.*

Finish the code on lines 2 and 3 in the code below to print how many hours and minutes you have been waiting when you have been waiting a total of 270 minutes. Remember that there are 60 minutes in an hour. It should print 4 and then 30.

Hint: don’t forget the difference between division and integer division.

You have attempted of activities on this page