Advertisement
fabgonber

pregunta 2 cristian cruz ( mira quen llego, soy yo!)

Oct 25th, 2022
561
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class Auto:
  2.  
  3.     def __init__(self, cilindrada, tipoCombustible, anoFabricacion,nPasajeros,patente,peso,precio):
  4.         self.cilindrada = cilindrada
  5.         self.tipoCombustible =tipoCombustible
  6.         self.anoFabricacion = anoFabricacion
  7.         self.nPasajeros =nPasajeros
  8.         self.patente =patente
  9.         self.peso =peso
  10.         self.precio =precio
  11.  
  12.  
  13. listaAutos = []
  14. p=1
  15. while p != 0 :
  16.    
  17.     print("Registro de automovil")
  18.     c = input("Ingrese la cilindrada: ")
  19.     tc = input("Ingrese tipo de combustible: ")
  20.     af = input("Ingrese año de fabricacion: ")
  21.     np = input("Ingrese numero de pasajeros: ")
  22.     p = input("Ingrese numero de patente: ")
  23.  
  24.     pe = input("Ingrese peso: ")
  25.     pr = input("Ingrese precio: ")
  26.     au1 = Auto(c,tc,af,np,p,pe,pr)
  27.     listaAutos.append(au1)
  28.     print("Automovil ingresado")
  29.     if p == 0:
  30.         p=0
  31.         print("Fin ingresos")
  32.     break ## PROF: break se ejecuta siempre
  33.  
  34. ordenados= sorted(listaAutos, key=lambda x: x.peso) #ordenar por peso
  35. print(ordenados)
  36. sumatotal= sum(listaAutos, key=lambda x: x.precio)
  37.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement