Problem 1: Day of the Week The modulus operator is denoted by the symbol %. For...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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])) 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]))
Expert Answer:
Related Book For
Introduction to Management Science A Modeling and Cases Studies Approach with Spreadsheets
ISBN: 978-0078024061
5th edition
Authors: Frederick S. Hillier, Mark S. Hillier
Posted Date:
Students also viewed these programming questions
-
answer all questions as instructed below. make sure you have attended all questions .Comparative Architectures (a) Describe the organisation of a two-level branch predictor that makes use of a global...
-
"internet radios" for streaming audio, and personal video recorders and players. Describe design and evaluation processes that could be used by a start-up company to improve the usability of such...
-
What is the main difference between n-type and p-type semiconductors?
-
The cost of a nation's market basket in the base year is $1,200, and the current year's price index equals 125. What is the cost of the market basket in the current year?
-
A city is planning to build a hydroelectric power plant. A local newspaper found that 53% of the voters in this city favor the construction of this plant. Assume that this result holds true for the...
-
Mrs. Palsgraf was waiting for a train on a platform of a railroad. When a different train came into the station, two men ran to get on that train before it left the station. While one of the men...
-
The owner of Brooklyn Restaurant is disappointed because the restaurant has been averaging 4,000 pizza sales per month but the restaurant and wait staff can make and serve 6,000 pizzas per month. The...
-
It is argued that decisions made in relatively risk-free environments are not optimal or not efficient. If this assertion is true, can we declare that the decision-making environment constrained by...
-
Create Car Rent application using Flutter that meets the following requirements. Task1: Each Car is described by by ID, CarModel, CarColor, Year, Price and Image. It is your responsibility to assign...
-
Francisco has asked you to provide a memo explaining what risk management techniques you would use to control the property and liability risks you identified in Part I. Your memo should be 3-5 pages...
-
Identify the specific media types that you would utilize to advertise amazon that you identified. Additionally, justify your use of these specific media types and assign a percentage of your media...
-
Blue Mountain Distributors has a $40 million bond outstanding that carries a 12 percent coupon rate paid annually. Current bonds yield are 9.5 percent. The $40 million bond was issued 20 years ago...
-
The Oklahoma State Board of Virtual Charter Schools, which considers applications for charter schools operating virtually in the state, denied the application in a 5-0 vote. Board President Robert...
-
Review the narrative write- up resulting from interviews with the company's Purchasing Agent, Director of Accounting Payable and the Controller. Identify weaknesses in internal controls, provide a...
-
Wildcat plans a major capital outlay in the second quarter of $85 million. Finally, the company started the year with a cash balance of $81 million and wishes to maintain a $30 million minimum...
-
Suppose the concentration of glucose inside a cell is 0.1 mm and the cell is suspended in a glucose solution of 0.01 mm. a. What would be the free energy change involved in transporting 10-o mole of...
-
Greg is making plans to open a new fast-food restaurant soon. He is estimating that customers will arrive randomly at a mean rate of 150 per hour during the busiest times of the day. He is planning...
-
Betsy Pitzer makes decisions according to Bayes' decision rule. For her current problem, Betsy has constructed the following payoff table (in units of dollars). a. Which alternative should Betsy...
-
Each time an unbiased coin is flipped three times, the probability of getting 0, 1, 2, and 3 heads is , , , and , respectively. Therefore, with eight groups of three flips each, on the average, one...
-
True or false? Economic theory argues that discrimination should be eliminated. Why?
-
Why is discrimination based on characteristics that affect job performance difficult to eliminate?
-
Visit the Suzy Lamplugh Trust website at http://www.suzylamplugh.org and the Social Research Association at http://the-sra.org.uk/sra_resources/safety-code/ . Browse the guidance leaflets/web pages...
Study smarter with the SolutionInn App