Write a function named month_apart (ml, d1, m2, d2) that accepts four integer parameters representing two...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Write a function named month_apart (ml, d1, m2, d2) that accepts four integer parameters representing two calendar dates. Each date consists of a month (1 through 12) and a day (1 through the number of days in that month [28-31]). Assume that all dates occur during the same year. The function returns whether the dates are at least one month apart. For example, the following dates are all considered to be at least a month apart from 9/19 (September 19): 2/14, 7/25, 8/2, 8/19, 10/19, 10/20, and 11/5. On the other hand, the following dates are NOT at least a month apart from 9/19: 9/20, 9/28, 10/1, 10/15, and 10/18. Note that the first date could come before or after (or be the same as) the second date. Assume that all parameter values passed are valid. Sample calls: month apart ( 6, 14, 9, 21) should return True, because June 14 is at least a month before September 21 month_apart (4, 5, month_apart ( 4, 15, 5, 15) should return True, because April 5 is at least a month before May 5, 15) should return True, because April 15 is at least a month before May 15 month apart 4, 16, 5, 15) should return False, because April 16 isn't at least a month apart from May 15 15 month_apart ( 6, 14, 6, from June 8 month_apart ( 7, 7, 6, June 8 8) should return False, because June 14 isn't at least a month apart 8) should return False, because July 7 isn't at least a month apart from month_apart ( 7, 8, 6, 8) should return True, because July 8 is at least a month after June 8 month_apart (10, 14, 7, 15) should return True, because Oct 14 is at least a month after July 15 Write a function named month_apart (ml, d1, m2, d2) that accepts four integer parameters representing two calendar dates. Each date consists of a month (1 through 12) and a day (1 through the number of days in that month [28-31]). Assume that all dates occur during the same year. The function returns whether the dates are at least one month apart. For example, the following dates are all considered to be at least a month apart from 9/19 (September 19): 2/14, 7/25, 8/2, 8/19, 10/19, 10/20, and 11/5. On the other hand, the following dates are NOT at least a month apart from 9/19: 9/20, 9/28, 10/1, 10/15, and 10/18. Note that the first date could come before or after (or be the same as) the second date. Assume that all parameter values passed are valid. Sample calls: month apart ( 6, 14, 9, 21) should return True, because June 14 is at least a month before September 21 month_apart (4, 5, month_apart ( 4, 15, 5, 15) should return True, because April 5 is at least a month before May 5, 15) should return True, because April 15 is at least a month before May 15 month apart 4, 16, 5, 15) should return False, because April 16 isn't at least a month apart from May 15 15 month_apart ( 6, 14, 6, from June 8 month_apart ( 7, 7, 6, June 8 8) should return False, because June 14 isn't at least a month apart 8) should return False, because July 7 isn't at least a month apart from month_apart ( 7, 8, 6, 8) should return True, because July 8 is at least a month after June 8 month_apart (10, 14, 7, 15) should return True, because Oct 14 is at least a month after July 15
Expert Answer:
Answer rating: 100% (QA)
You can implement the monthapart function in Python like this def daysinmonthmont... View the full answer
Related Book For
Building Java Programs A Back To Basics Approach
ISBN: 9780135471944
5th Edition
Authors: Stuart Reges, Marty Stepp
Posted Date:
Students also viewed these programming questions
-
Problem 5.10 The total head against which a steam driven pump operates is expressed as 160 psig. The pump develops 84 ihp, discharges 720 gpm of water at a temperature of 180F, receives steam with...
-
Managing Scope Changes Case Study Scope changes on a project can occur regardless of how well the project is planned or executed. Scope changes can be the result of something that was omitted during...
-
Design a Java class that represents a cache with a fixed size. It should support operations like add, retrieve, and remove, and it should evict the least recently used item when it reaches capacity.
-
According to Kurt Lewin, why is it so difficult to motivate employees to alter their patterns of behavior?
-
Refer to problem 9. If your marginal tax rate is 30%, and 50% of capital gains are taxable, what is the after-tax rate of return on your bond investment? In problem 9 You bought a 10-year, 5% coupon...
-
(S)-1-Bromo-1,2-diphenylethane reacts with a strong base to produce cis-stilbene and trans-stilbene: a) This reaction is stereo-selective, and the major product is trans-stilbene. Explain why the...
-
Horizontal analysis is: a. The calculation of the relative weighting of components within a financial statement in a particular financial period b. The comparison of the current year's figures with...
-
In the GMP partnership (to which Elan seeks admittance), the capital balances of Mary, Gene, and Pat, who share income in the ratio of 6:3:1, are Mary ........ $240,000 Gene ......... 120,000 Pat...
-
Directions: Determine whether a permutation or combination can be used. Then solve. 19. Three cards from a standard deck of 52 cards are chosen at random. What is the probability that all three cards...
-
Sofia Lofts case, but under a new set of assumptions on page 11 of the case. First re-read the Sofia Lofts case, then click here to download the new page 11. Specifically, you are to write up a brief...
-
Additionally, Loi said Farm Fresh intends to roll out regenerative agriculture practices across all its farms by 2024. "These are practices that involve the recycling and reuse of liquid and solid...
-
You state, "The Financial Service Sector is an important issue because of its vital role in ensuring that the nation's economy is functional. Regarding the security of the nation, today, many...
-
As a financial manager, Aabha must consider the probability of changing conditions that could affect her forecast when making long-term decisions about the purchase of fixed assets. When assessing...
-
Find the area of the triangle. a = 13, b = 14, c = 22
-
1,List and discuss the salient features of the Four Components of SMS. 2, Compare and contrast the differences between hazards and risks. 3, Describe the steps of the SMS maturity model used for SMS...
-
Testing: H : A = 53.47 H> 53.47 : Your sample consists of 23 subjects, with a mean of 54.7 and a sample standard deviation (s) of 2.86 Calculate the test statistic, rounded to 2 decimal places. t
-
It is the beginning of September and you have been offered the following deal to go heli-skiing. If you pick the first week in January and pay for your vacation now, you can get a week of heli-skiing...
-
What are the before image (BFIM) and after image (AFIM) of a data item? What is the difference between in-place updating and shadowing, with respect to their handling of BFIM and AFIM?
-
Finish the following client code so that it constructs two Point objects, translates each, and then prints their coordinates.
-
Write a method called swapPairs that accepts an array of integers and swaps the elements at adjacent indexes. That is, elements 0 and 1 are swapped, elements 2 and 3 are swapped, and so on. If the...
-
The following piece of code incorrectly attempts to find the largest value in a queue of integers. What is wrong with the code, and how would you fix it? int largest = q.remove () ; for (int i = 0; i...
-
What problems can result from the use of tight standards?
-
How is a cost center different from either an investment or a profit center?
-
How is standard labor time determined? Explain the two ways.
Study smarter with the SolutionInn App