Generation

generate functionThu, 25 May 2023

Realiza un programa que solicite al usuario la cantidad de pasteles que va a comprar, despues de preguntarle el precio de cada uno, debera guardar el total de esa cantidad y mostrar un mensaje final con el monto total de la compra. Despues, debera calcular un descuento, si el total de la compra fue mayor a 800 pesos debera aplicarle un 15% de descuento e imprimir el mensaje con el nuevo total. Si es 800 o menos, solo aplicara el 5%.

def discount(): items = int(input("How many items are you buying?: ")) total = 0 for i in range(items): price = int(input("What is the price of the item?: ")) total = total + price print("Your total is: " + str(total)) if (total > 800): discount = total * 0.15 print("You get a 15% discount of: " + str(discount)) total = total - discount print("Your total is now: " + str(total)) else: discount = total * 0.05 print("You get a 5% discount of: " + str(discount)) total = total - discount print("Your total is now: " + str(total)) discount()

Want to kickstart your project?Use the new AI Studio to create your code