Advertisement
teslariu

integrador v2

Mar 28th, 2022
970
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.54 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. #
  4. """
  5. Ejemplo:
  6. alumnos = {"Juan":3, "Ana":5, "Tito":4}
  7.  
  8. Lista de alumnos:
  9. Pablo - 3 cursos
  10.  
  11.  
  12. """
  13. print("Administración de alumnos")
  14. alumnos = {}
  15. while True:
  16.     eleccion = input(
  17.     """
  18.     Elige una opcion:
  19.     1- Ingresar alumno
  20.     2- Ver lista de alumnos
  21.     3- Ver cantidad de cursos de un alumno
  22.     4- salir
  23.     """)
  24.    
  25.     if eleccion == "1":
  26.         while True:
  27.             nombre = input("Ingrese el nombre del alumno: ")
  28.             if not nombre.isspace() and len(nombre):
  29.                 break
  30.             else:
  31.                 print("No puede dejar el nombre en blanco")
  32.        
  33.        
  34.         while True:
  35.             cursos = input("Ingrese la cantidad de cursos suscriptos: ")
  36.             if cursos.isdecimal() and cursos!="0":
  37.                 cursos = int(cursos)
  38.                 break
  39.             else:
  40.                 print("Error, debe ingresar un nro entero mayor a cero")
  41.         alumnos[nombre] = cursos
  42.    
  43.    
  44.     elif eleccion == "2":
  45.         if alumnos:
  46.             print("Lista de alumnos:")
  47.             for nombre,cursos in alumnos.items():
  48.                 print(f"{nombre} - {cursos} cursos")
  49.         else:
  50.             print("No hay alumnos inscriptos")
  51.            
  52.            
  53.     elif eleccion == "3":
  54.         while True:
  55.             nombre = input("Ingrese el nombre del alumno: ")
  56.             if not nombre.isspace() and len(nombre):
  57.                 break
  58.             else:
  59.                 print("No puede dejar el nombre en blanco")
  60.        
  61.         nombres = list(alumnos.keys())
  62.         if nombre in nombres:
  63.             print(f"{nombre} - {alumnos[nombre]} cursos")
  64.         else:
  65.             print(f"No existe el alumno {nombre}")
  66.        
  67.            
  68.        
  69.     elif eleccion == "4":
  70.         print("gracias por utilizar esta aplicacion.")
  71.         break
  72.        
  73.     else:
  74.         print("Opción incorrecta")
  75.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement