Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Auto:
- def __init__(self, cilindrada, tipoCombustible, anoFabricacion,nPasajeros,patente,peso,precio):
- self.cilindrada = cilindrada
- self.tipoCombustible =tipoCombustible
- self.anoFabricacion = anoFabricacion
- self.nPasajeros =nPasajeros
- self.patente =patente
- self.peso =peso
- self.precio =precio
- listaAutos = []
- p=1
- while p != 0 :
- print("Registro de automovil")
- c = input("Ingrese la cilindrada: ")
- tc = input("Ingrese tipo de combustible: ")
- af = input("Ingrese año de fabricacion: ")
- np = input("Ingrese numero de pasajeros: ")
- p = input("Ingrese numero de patente: ")
- pe = input("Ingrese peso: ")
- pr = input("Ingrese precio: ")
- au1 = Auto(c,tc,af,np,p,pe,pr)
- listaAutos.append(au1)
- print("Automovil ingresado")
- if p == 0:
- p=0
- print("Fin ingresos")
- break ## PROF: break se ejecuta siempre
- ordenados= sorted(listaAutos, key=lambda x: x.peso) #ordenar por peso
- print(ordenados)
- sumatotal= sum(listaAutos, key=lambda x: x.precio)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement