Question: Problem 1: Day of the Week The modulus operator is denoted by the symbol %. For x%y it returns the remainder after y is



Problem 1: Day of the Week The modulus operator is denoted by the symbol %. For x%y it returns the remainder after y is di- vided into x a whole number of times. While you've seen this before, the format is likely different. To refresh your memory you can visit https://realpython.com/python-modulo-operator/ or do your own search. For this problem, you will also need to use the floor function in python - think of floor as a way to round down a floating point number to the nearest integer. For example, floor (18.90) is 18 and floor(14.25) is 14. An approximate (works generally okay for a number of dates, but not all) formula for com- puting the day of the week given dlst = [d,m,y] where d is day, m is month, and y is year is: For example, dlst = a (dlst) = X = b(dlst) c(dlst) day ((d, m, y)) (3) (4) (5) (6) The function day returns a number 1, 2, ..., 7 where 1 = Monday, 2 = Tuesday,.... If we use this number as the key with the week dictionary, we are able to return the correct day of the week. Here is the dictionary used: = = [d, m, y] = y - (14 - m) 12 a(dlst) a(dlst) a(dlst) + 4 100 400 a(dl st) + floor (x) m+12(4-m 12 (d+b(dlst) + (31. 1 week = {1: "Mon", 2: "Tue", 3: "Wed", 4:"Thu", 5:"Fri", 6:"Sat", 7:"Sun"} - 2 day ([14, 2, 2000]) print(day([14, 2, 1963])) print(day([14, 2, 1972])) = c(dl st) 12 = -))%7 2/14/2000 falls on a Monday; 2/14/1963 falls on a Thursday; 2/14/1972 falls on a Monday. Deliverables for Problem 1 Complete the functions described above. For calculating b(dlst), you can use the math.floor() function from the math library. Remember, the day function utilizes the week dictionary. Mon Thu Mon (1) (2) (7) (8) (9) # Functions for Problem 1 ##### #INPUT dlst = [day, month, year] #RETURN string corresponding to the day of the week (i.e. "Mon", "Sun", etc) {1:"Mon", 2:"Tue", 3: "Wed", 4:"Thu", 5:"Fri", 6:"Sat", 0:"Sun"} week = def a(dlst): def b(dlst): def c(dlst): def day (dlst): # #problem 1 print (day ([14,2,2000])) print (day ([14,2, 1963])) print (day([14,2,1972]))
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
