Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

 


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

Step by Step Solution

There are 3 Steps involved in it

Step: 1

You can implement the monthapart function in Python like this def daysinmonthmont... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Building Java Programs A Back To Basics Approach

Authors: Stuart Reges, Marty Stepp

5th Edition

013547194X, 978-0135471944

More Books

Students also viewed these Programming questions

Question

1. Walk to the child, look into his or her eyes.

Answered: 1 week ago