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
-
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?
-
Assume that the term structure is upward-sloping. How would you respond to the following statement? Given the current yield curve, a company should borrow short-term rather than long-term. It will be...
-
Use MS Excel to list all of the invoice lines for Invoice 1003 using the Ch02_SaleCo System DSN.
-
A dicing system has a first cost of $\$ 68,000$ with a life of 8 years and a salvage value of probably not more than $\$ 9,000$. The corporate MARR is $14 \%$. If the system has a maintenance cost of...
-
Discuss the sequence in which the major components of the master budget are prepared. Why is it necessary to prepare the components in such a sequence?
-
How do conflict resolution professionals navigate ethical dilemmas when mediating disputes between stakeholders with competing interests, balancing impartiality with the pursuit of equitable outcomes?
-
Dan Goodley says that disability is a political issue. This short clip is meant to introduce you to a few terms (marginalization, disablism, human diversity) that will provide some context or ways of...
-
blocks away can carry no more than ten passengers. There are 23 people waiting at the The free trolley between the downtown Life Sciences Building and its parking structure six city parking structure...
-
A dish of hot food has an emissivity of 0.43 and emits 16 W of thermal radiation. If you wrap it in aluminum foil, which has an emissivity of 0.06, how much power will it radiate? Pfoil = i
-
Calculate the July and August cost of goods sold and gross margin ratios for Fletcher Corporation. July 2027 August 2027 Cost of Goods Sold $70,200 $67,500 Total Sales $147,900 $146,100 1: Cost of...
-
Yanni owns a factory and purchases some heavy equipment from ABC, Inc. Yanni signs a note with ABC, Inc. in the amount of $1 million, which is payable in equal installments over the next 5 years. One...
-
If three different forces acted from the single point is going towards different directions with various magnitude as given below. Represent these three forces in vector form and, use appropriate...
-
By what magnitude is the internal energy of 1.0 mole of an ideal gas at a steam point greater/smaller than the same quantity of the ideal gas at an ice point?
-
(a) Water flows through the nozzle of a garden hose. Find an expression for m in terms of line pressure P 1 , ambient pressure P 2 , inside hose diameter D 1 , and nozzle outlet diameter D 2 . Assume...
-
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...
-
Mosca and Vespa are two sole traders with the financial statements (in euros) for the year ending 31 December as set out in Figure 7.10. Using the information contained in the financial statements,...
-
The following information has been extracted from the recently published statements of company D, as set out in Figure 7.11. Figure 7.11 Financial statements for company D as at 30 April The ratios...
-
Which of the following costs related to a building is NOT usually treated as an expense but is added to the asset? A. Repairs. B. Redecoration. C. Fitting new safety equipment. D. Cleaning.
Study smarter with the SolutionInn App