Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- #
- '''
- 1) Pedir el ingreso de notas. La condición de salida es nota = -1.
- Luego, mostrar su promedio y el total de notas
- 2) Hacer un template while true con opciones de calculo de perimetros
- y superficies: circulo, cuadrado, etc
- # 1)
- contador = 0
- notas = []
- while True:
- nota = int(input("Ingrese una nota: "))
- if 0 <= nota <= 10:
- notas.append(nota)
- elif nota == -1:
- break
- else:
- print("Error en el ingreso de la nota")
- print(f"""
- Total de notas: {len(notas)}
- Promedio: {sum(notas)/len(notas):.2f}
- """)
- '''
- # 2)
- print("""
- *---------------------------------*
- | Cálculo de áreas y perímetros |
- *_________________________________*
- """)
- while True:
- print("""
- Menu de opciones:
- -----------------
- 1. Círculo
- 2. Cuadrado
- 3. Rectángulo
- 4. Salir
- -----------------
- """)
- opcion = input("Ingrese una opción: ")
- if opcion == "1":
- radio = float(input("Ingrese el radio: "))
- print(f"Area: {3.1416*radio**2:.2f} - Perímetro: {2*3.1416*radio:.2f}")
- elif opcion == "2":
- lado = float(input("Ingrese el lado: "))
- print(f"Area: {lado**2:.2f} - Perímetro: {4*lado:.2f}")
- elif opcion == "3":
- a = float(input("Ingrese un lado: "))
- b = float(input("Ingrese el otro lado: "))
- print(f"Area: {a * b:.2f} - Perímetro: {2*(a + b):.2f}")
- elif opcion == "4":
- print("Gracias por utilizar este script...")
- break
- else:
- print("Opción incorrecta")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement