LexarG56

Generation

generate functionFri, 16 Jun 2023

Generar un menú que tenga las opciones: 1. Sumar 2. Restar 3. Multiplicar 4. Dividir 5. Salir

Script def menu(): choice = int(input('Selecciona una opción: \n1. Sumar\n2. Restar\n3. Multiplicar\n4. Dividir\n5. Salir\n')) return choice def add(a, b): return a + b def sub(a, b): return a - b def mul(a, b): return a * b def div(a, b): return a / b def calculate(choice, a, b): if choice == 1: return add(a, b) elif choice == 2: return sub(a, b) elif choice == 3: return mul(a, b) elif choice == 4: return div(a, b) while True: choice = menu() if choice != 5: a = int(input('Ingresa el primer valor: ')) b = int(input('Ingresa el seg

Questions about programming?Chat with your personal AI assistant