Advertisement
teslariu

template2

Dec 2nd, 2021
983
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.89 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. #
  4. # Segundo ejemplo de un template con menu
  5.  
  6. print("Calculo de superficies y perimetros")
  7. while True:
  8.     print("\nMenu de opciones")
  9.     print("1. Cuadrado")
  10.     print("2. Círculo")
  11.     print("3. Rectángulo")
  12.     print("4. Salir")
  13.    
  14.     opcion = input("Seleccione una opción: ")
  15.    
  16.     if opcion == "1":
  17.         l = float(input("Ingrese el lado: "))
  18.         print(f"Superficie: {l**2}")
  19.         print(f"Perímetro: {4*l}")
  20.        
  21.     elif opcion == "2":
  22.         r = float(input("Ingrese el radio: "))
  23.         print(f"Superficie: {3.1416 * r**2}")
  24.         print(f"Perímetro: {2 * 3.1416 * r}")
  25.        
  26.     elif opcion == "3":
  27.         l = float(input("Ingrese el lado menor: "))
  28.         L = float(input("Ingrese el lado mayor: "))
  29.         print(f"Superficie: {l*L}")
  30.         print(f"Perímetro: {2*(l+L)}")
  31.        
  32.     elif opcion == "4":
  33.         print("Gracias por usar este programa...")
  34.         break
  35.    
  36.     else:
  37.         print("Opción incorrecta...")
  38.    
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement