Problem 1

Evaluate the following numerical expressions in your head, then use the Python interpreter to check your results:

>>> 5 % 2
>>> 9 % 5
>>> 15 % 12
>>> 12 % 15
>>> 6 % 6
>>> 0 % 7

Problem 3

You look at the clock and it is exactly 2pm. You set an alarm to go off in 51 hours.

Write a Python program to solve the general version of the above problem. Ask the user for the time now (in hours), and ask for the number of hours to wait. Your program should output what the time will be on the clock when the alarm goes off.

Problem 4

Assume the days of the week are numbered 0,1,2,3,4,5,6 from Sunday to Saturday. Write a function which is given the day number, and it returns the day name (a string).

Problem 6

Give the logical opposites of these conditions

a > b
a >= b
a >= 18 and day == 3
a >= 18 and day != 3

Problem 7

What do these expressions evaluate to?

3 == 3
3 != 3
3 >= 4
not (3 < 4)

Problem 8

Write a function which is given an exam mark, and it returns a string the grade for that mark according to this scheme:

Mark Grade
>= 75 First
[70 - 75) Upper Second
[60 - 70) Second
[45 - 50) F1 Supp
[40 - 45) F2
< 40 F3

The square and round brackets denote closed and open intervals. A closed interval includes the number, and open interval excludes it. So, 39.99999 gets grade F3, but 40 gets grade F2. Assume

xs = [83, 75, 74.9, 70, 69.9, 65, 60, 59.9, 55, 50, 49.9, 45, 44.9, 40, 39.9, 2, 0]

Test your function by printing the mark and the grade for all the elements in this list.

Problem 12

Write a function find_hypot which, given the length of two sides of a right-angled triangle, returns the length of the hypotenuse. (Hint: x ** 0.5 will return the square root.)

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.