Answer:
Here is the function month_days:
def month_days(month, days):
print (month +" has " + str(days) + " days.")
Now call this function by passing values to it as:
month_days ("June", 30)
month_days("July", 31)
The above function can also be written as:
def month_days(month, days):
return (month +" has " + str(days) + " days.")
Now call this function by passing values to it and using print function to see the result on output screen:
print(month_days ("June", 30))
print(month_days("July", 31))
Explanation:
The above code has a function month_days which receives two arguments i.e. month which is the name of the month and days which is the number of days in that month. The method has a statement return (month +" has " + str(days) + " days.") which returns the name of the month stored in month variable followed by has word followed by the number of days stored in days variable which is followed by the word string days.
So if user passes "June" as month and 30 as days then the program has the following output:
June has 30 days.
The above program can also be written by using f-string to specify the format of the output in function month_days:
def month_days(month, days):
output = f"{month} has {days} days."
return (output)
Now call this function to see the output on the screen
print (month_days("June", 30))
print (month_days("July", 31))
The f-string is prefixed with 'f', which contains arguments month and days inside braces. These expressions i.e. month and days are replaced with their values specified in the calling statement.
Screenshot of the program and its output is attached.