Answer:
Below is the month_days function:
def month_days(month, days):
print (month +" has " + str(days) + " days.")
You can invoke this function with arguments like:
month_days ("June", 30)
month_days("July", 31)
The function can also be restructured as follows:
def month_days(month, days):
return (month +" has " + str(days) + " days.")
To view the output, call the function along with print like this:
print(month_days ("June", 30))
print(month_days("July", 31))
Explanation:
The defined month_days function takes two parameters: the month name and the number of days in that month. It has a return statement return (month +" has " + str(days) + " days.") which combines the month name held in the variable month with the word "has" and then the number of days stored in days followed by the term days.
For instance, if "June" is passed in as month and 30 as days, the output will be:
June has 30 days.
This program can also be constructed using an f-string for better formatting in the month_days function:
def month_days(month, days):
output = f"{month} has {days} days."
return (output)
To see the output, invoke the function with print:
print (month_days("June", 30))
print (month_days("July", 31))
The f-string starts with 'f' and includes the parameters month and days within curly braces. The variables month and days are substituted with their respective values when the function is called.
Screenshot of the program and its output is attached.