Final answer:
The Python program allows the user to choose fillings for a crepe, calculates the cost of the fillings, and the total cost for the specified number of crepes. It demonstrates modular programming with a main function and two additional functions, one using parameters and the other returning a value.
Step-by-step explanation:
To write a Python program that allows a user to build a custom made crepe, you need to apply the basic concepts of programming such as loops, functions, I/O operations, and simple arithmetic operations. The following program incorporates these principles:
Python Program for Crepe Order System
# Define the base price of a crepe
BASE_PRICE = 2.0
# Define fillings and their prices
FILLINGS_PRICES = {
'Cheese': 0.5,
'Ham': 0.7,
'Chocolate': 0.6
}
# Function to display filling options and get choice
def choose_fillings():
total_fillings_price = 0
while True:
print("Choose a filling (or Q to quit):")
for filling, price in FILLINGS_PRICES.items():
print(f"{filling} (${price})")
choice = input("What filling would you like? ")
if choice == 'Q':
break
if choice in FILLINGS_PRICES:
total_fillings_price += FILLINGS_PRICES[choice]
else:
print("Invalid choice. Please try again.")
return total_fillings_price
# Function to calculate the total price
def calculate_total(crepes_count, fillings_cost):
return crepes_count * (BASE_PRICE + fillings_cost)
# Main function
def main():
print("Welcome to the Crepe Maker!")
fillings_cost = choose_fillings()
print(f"The price for fillings is: $({fillings_cost:.2f})")
crepes_count = int(input("How many crepes would you like to purchase? "))
total_cost = calculate_total(crepes_count, fillings_cost)
print(f"The total price is: ${total_cost:.2f}")
if __name__ == '__main__':
main()