Advertisement
ABE12unju

Untitled

Sep 25th, 2021
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 4.24 KB | None | 0 0
  1. import os
  2.  
  3. def continuar():
  4.     print()
  5.     input('Presione una tecla para continuar ...')
  6.     os.system('cls')
  7.  
  8. def menu():
  9.     print('1) Agregar Empleado')
  10.     print('2) Mostrar empleados ')
  11.     print('3) Cabiar Departamento')
  12.     print('4) ordenar de forma Decendente')
  13.     print('5) Mostrar')
  14.     print('6) Salir')
  15.     eleccion = int(input('Elija una Opción: '))
  16.     while not((eleccion >= 1) and (eleccion <= 6)):
  17.         eleccion = int(input('Elija una Opción: '))
  18.     os.system('cls')
  19.     return eleccion
  20.  
  21. def leerNombre():
  22.     nombre = input('Nombre: ')
  23.     while not (nombre!=""):
  24.         nombre = input('Nombre: ')
  25.     return nombre
  26.  
  27. def leerDepart():
  28.     dep = int(input('Departamento (1/2/3): '))
  29.     while not((dep==1) or (dep==2) or (dep==3)):
  30.         dep = int(input('Departamento (1/2/3): '))
  31.     return dep
  32.  
  33. def leerSalario():
  34.     precio = float(input('Salario: '))
  35.     while not(precio > 0):
  36.         precio = float(input('Salario: '))
  37.     return precio
  38.  
  39. def leerEmail(empleado):
  40.     em = str(input("Email: "))
  41.     for (i,item) in enumerate(empleado):
  42.         while not ((item[2]!=em)and("@" in em)and(em[0]!="@")):
  43.             print("Ya Existeo o no valido")
  44.             em = str(input("Email: "))
  45.     return em
  46.    
  47.  
  48. def leerIdent(empleado):
  49.     iden=int(input("Ingrese Id: "))
  50.     for (i,item) in enumerate(empleado):
  51.         while (item[0]==iden):
  52.             print("Ya Existe")
  53.             iden=int(input("Ingrese Id: "))
  54.     return iden
  55.  
  56. def leerLista(empleado):
  57.     empleado=[
  58.     [100, "Steven King", "king@gmail.com", "Gerencia", 24000],
  59.     [101, "Neena Kochhar", "neenaKochhar@gmail.com", "Ventas", 17000],
  60.     [102, "Lex De Haan", "lexDeHaan@gmail.com", "Compras", 16000],
  61.     [103, "Alexander Hunold", "alexanderHunold@gmail.com", "Compras", 9000],
  62.     [104, "David Austin", "davidAustin@gmail.com", "Compras", 4800],
  63.     [105, "Valli Pataballa", "valliPataballa@gmail.com", "Ventas", 4200],
  64.     [106, "Nancy Greenberg", "nancyGreenberg@gmail.com", "Ventas", 5500],
  65.     [107, "Daniel Faviet", "danielFaviet@gmail.com", "Ventas", 3000],
  66.     [108, "John Chen", "johnChen@gmail.com", "Compras", 8200],
  67.     [109, "Ismael Sciarra", "ismaelSciarra@gmail.com", "Compras", 7700],
  68.     [110, "Alexander Khoo", "alexanderKhoo@gmail.com", "Comrpas", 3100]]
  69.     respuesta = "s"
  70.     while respuesta != "n":
  71.         iden=leerIdent(empleado)
  72.         nombre=leerNombre()
  73.         dep=leerDepart()
  74.         if dep==1:
  75.                 departamento="Gerencia"
  76.         elif dep==2:
  77.                 departamento="Ventas"
  78.         else:
  79.                 departamento="Compras"
  80.         email=leerEmail(empleado)
  81.         salario=leerSalario()
  82.         empleado.append([iden,nombre,email,departamento,salario])
  83.         respuesta = input("DESEA AGRECAR s/n: ")
  84.     return empleado
  85.  
  86. def modificarDep(empleado):
  87.     iden=int(input("Ingrese Id: "))
  88.     depa=input("Nuevo Departamento Ventas/Gerencia/Compras: ")
  89.     for (i,item) in enumerate(empleado):
  90.         if (item[0]==iden):
  91.             item[3]=depa
  92.             print("Modificado")
  93.             break
  94.         else:
  95.             print("No existe")
  96.  
  97. def bubbleSort(empleado):
  98.     n = len(empleado)
  99.     for i in range(n):
  100.         for j in range(0, n-1):
  101.             if empleado[j][1] < empleado[j+1][1]:
  102.                 empleado[j][1], empleado[j+1][1] = empleado[j+1][1], empleado[j][1]
  103.     print(empleado)
  104.  
  105. def mostrarEm(empleado):
  106.     print('Empleados Desde el Id: ')
  107.     em1 = int(input("Ingrese Id: "))
  108.     print('Empleados hasta el Id: ')
  109.     em2 = int(input("Ingrese Id: "))
  110.     for cod, datos in enumerate(empleado):
  111.         if ((datos[0] >= em1) and (datos[0] <= em2)):
  112.             print(datos)    
  113.  
  114. def mostrar(empleado):
  115.     for pos, elem in enumerate(empleado):
  116.         print(elem)
  117.  
  118. def salir():
  119.     print('FIN DEL PROGRAMA....')
  120.  
  121. #principal
  122. empleado=()
  123. opcion = 0
  124. os.system('cls')
  125. while (opcion != 7):
  126.     opcion = menu()
  127.     if opcion == 1:
  128.         empleado=leerLista(empleado)
  129.     elif opcion == 2:
  130.         mostrarEm(empleado)
  131.     elif opcion == 3:
  132.         modificarDep(empleado)
  133.     elif opcion == 4:
  134.         bubbleSort(empleado)
  135.     elif opcion == 5:
  136.         mostrar(empleado)
  137.     elif (opcion == 6):        
  138.         salir()
  139.     continuar()
  140.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement