Advertisement
teslariu

ejercicios pendientes

Aug 24th, 2023
901
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.52 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. #
  4. '''
  5. 1) Pedir el ingreso de notas. La condición de salida es nota = -1.
  6. Luego, mostrar su promedio y el total de notas
  7.  
  8. 2) Hacer un template while true con opciones de calculo de perimetros
  9. y superficies: circulo, cuadrado, etc
  10.  
  11.      
  12. # 1)
  13. contador = 0
  14. notas = []
  15. while True:
  16.     nota = int(input("Ingrese una nota: "))
  17.     if 0 <= nota <= 10:
  18.         notas.append(nota)
  19.     elif nota == -1:
  20.         break
  21.     else:
  22.         print("Error en el ingreso de la nota")
  23.  
  24. print(f"""
  25. Total de notas: {len(notas)}
  26. Promedio: {sum(notas)/len(notas):.2f}
  27. """)
  28. '''
  29.  
  30. # 2)
  31. print("""
  32. *---------------------------------*
  33. | Cálculo de áreas y perímetros   |
  34. *_________________________________*
  35. """)
  36.  
  37. while True:
  38.     print("""
  39.     Menu de opciones:
  40.     -----------------
  41.     1. Círculo
  42.     2. Cuadrado
  43.     3. Rectángulo
  44.     4. Salir
  45.     -----------------
  46.     """)
  47.     opcion = input("Ingrese una opción: ")
  48.    
  49.     if opcion == "1":
  50.         radio = float(input("Ingrese el radio: "))
  51.         print(f"Area: {3.1416*radio**2:.2f} - Perímetro: {2*3.1416*radio:.2f}")
  52.        
  53.     elif opcion == "2":
  54.         lado = float(input("Ingrese el lado: "))
  55.         print(f"Area: {lado**2:.2f} - Perímetro: {4*lado:.2f}")
  56.        
  57.     elif opcion == "3":
  58.         a = float(input("Ingrese un lado: "))
  59.         b = float(input("Ingrese el otro lado: "))
  60.         print(f"Area: {a * b:.2f} - Perímetro: {2*(a + b):.2f}")
  61.        
  62.     elif opcion == "4":
  63.         print("Gracias por utilizar este script...")
  64.         break
  65.        
  66.     else:
  67.         print("Opción incorrecta")
  68.        
  69.    
  70.    
  71.    
  72.    
  73.    
  74.  
  75.  
  76.  
  77.  
  78.  
  79.  
  80.  
  81.  
  82.  
  83.  
  84.  
  85.  
  86.  
  87.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement