Conditionals

Problem 1: Write code that checks whether the variable x is divisible by 3 or divisible by 7. If it is divisible by 3 print ‘Your number is divisible by 3’. If it is divisible by 7 print ‘Your number is divisible by 7’. If it is divisible by both 3 and 7 print ‘Your number is divisible by both 3 and 7’. If it is not divisible by 3 or 7 print ‘Your number is not divisible by 3 or 7’.

Problem 2: Create two variables: h and r.

Write code that calculates the total salary that a person will make after working for h hours at r dollars per hour. If h is greater than 8 then the person should receive overtime pay which is twice the original rate r.

Below you can see the salary a person earns given certain values of h and r.

h = 7
r = 10
salary = 70

h = 10
r = 10
salary = 120

Problem 3: Create one variable: score.

Write code that prints out score along with a letter grade. If score is between 90 and 100 the letter grade is ‘A’. If score is between 80 and 89 the letter grade is ‘B’. If score is between 70 and 79 the letter grade is ‘C’. If score is between 60 and 69 the letter grade is ‘D’. If score is between 0 and 59 the letter grade is ‘F’. If score is any other number (less than 0 or greater than 100) the letter grade is ‘invalid’.