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
-
1. Diskin et al. studied common breath metabolites such as ammonia, acetone, isoprene, ethanol, and acetaldehyde in five subjects over a period of 30 days. Each day, breath samples were taken and...
-
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...
-
Q1. You have identified a market opportunity for home media players that would cater for older members of the population. Many older people have difficulty in understanding the operating principles...
-
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?
-
Given that f is a differentiable function with f (2, 5) = 6, f x (2, 5) = 1, and f y (2, 5) = -1, use a linear approximation to estimate f(2.2, 4.9).
-
What is the cost per batch of pencils if variable costing is used? a. $45 b. $105 c. $35 d. $109 Ariana Corp. makes pencils. The actual and budgeted overhead for the year was $350,000. The com- pany...
-
Using the following data from Moontrust Corporations financial statements, compute the receivables turnover and the days sales uncollected. (Round to one decimal place or to the nearest whole day.)...
-
A 1 xe x 23. f(x) = 24. f(x) = B+ Ce* x + ex X 25. f(x) = ax + b 26. f(x) = CX + d x + X
-
At the end of June, Rick Fontan decided to open his own computer service. Analyze the following transactions he completed by recording their effects in the expanded accounting equation. a. Invested...
-
a) You must design a pneumatic circuit which satisfies the following requirements from a customer. The system pressure must not exceed 6 Bar and you must clamp a component with 5KN of force, the...
-
find the domain of the following functions. Justify each step x a) f(x) = x-16 b) g(x)=3x-12
-
4. Suppose we have used a decision tree algorithm to build a classifi- cation tree model for detection of Fault-Prone (FP) and Not Fault- Prone (NFP) program modules or objects. We have encoded FP=0...
-
Computer charting is becoming an increasingly common way to document. How often should the password be changed?
-
3. (5 points) What is the entropy of the image below, where numbers (0, 48, 85, 92, 110) denote the gray-level intensities? 110 110 110 110 110 110 110 110 85 85 85 85 85 85 85 85 0 0 92 92 92 92 0 0...
-
The line x + 3y-2=0 bisects the angle between a pair of straight lines of which one has equation x-7y+5=0. The equation of the other line is:
-
A pizza delivery company classifies its customers by gender and location of residence. The research department has gathered data from a random sample of 1574 customers. The data is summarized in the...
-
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...
-
Estimated cost and operating data for three companies for the upcoming year follow: Predetermined overhead rates are computed using the following bases in the three companies: Required: 1. Compute...
-
Dillon Products manufactures various machined parts to customer specifications. The company uses a job-order costing system and applies overhead cost to jobs on the basis of machine-hours. At the...
-
The following information is taken from the accounts of Latta Company. The entries in the T-accounts are summaries of the transactions that affected those accounts during the year. Required: 1....
Study smarter with the SolutionInn App