Question
Optional Arguments in Functions Summary: In this lab, you complete a partially written Python program that computes hotel guest rates at Cornwalls Country Inn. The
Optional Arguments in Functions
Summary:
In this lab, you complete a partially written Python program that computes hotel guest rates at Cornwalls Country Inn.
The program is described in Chapter 9, Exercise 11, in Programming Logic and Design. In this program, you should include a function named computeRate(). It should accept the number of days and calculate the rate at $99.99 per day.
It should optionally include a code for a meal plan. If the code is A, three meals per day are included, and the price is $169.00 per day. If the code is C, breakfast is included, and the price is $112.00 per day. All other codes are invalid.
The function returns the rate to the calling program where it is displayed. The main program asks the user for the number of days in a stay and whether meals should be included; then, based on the users response, the program either calls the function or prompts for a meal plan code and calls the function. Comments are included in the file to help you write the remainder of the program.
Instructions:
Make sure the file Cornwall.py is selected and open.
Write the Python statements as indicated by the comments.
Execute the program by the clicking the "Run Code" button at the bottom of the screen.
Assignment (Cornwall.py)
# Cornwall.py - This program computes hotel guest rates. # Input: Days in stay and meals included # Output: Hotel guest rate
# Write computeRate function here
if __name__ == '__main__': rate = 0.00 dayString = input("How many days do you plan to stay? ") days = int(dayString) question = input("Do you want a meal plan? Y or N")
# Figure out which arguments to pass to the computeRate() function and # then call the computeRate() functio
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started