Toxotsist

Task 5

Feb 26th, 2021
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.10 KB | None | 0 0
  1. def all(cars):
  2.     for i in cars:
  3.         print(i)
  4.  
  5. def id(cars):
  6.     id = input()
  7.     for i in cars:
  8.         if i["id"] == id:
  9.             print(i)
  10.  
  11. def refresh(cars, id):
  12.     for i in cars:
  13.         if i["id"] == id:
  14.             i["id"]  = int(input("id:"))
  15.             i["model"] = str(input("model:"))
  16.             i["rate"] = int(input("rate:"))
  17.             i["country"] = str(input("country:"))
  18.     return cars
  19.  
  20. def delete(cars):
  21.     id = input()
  22.     for i in cars:
  23.         if i["id"] == id:
  24.             del cars[id-1]
  25.     return cars
  26.  
  27. def number(cars):
  28.     year = input()
  29.     count = 0
  30.     for i in cars:
  31.         if i["year"] < year:
  32.             count += 1
  33.     print(count)
  34.  
  35. cars = [{"id": 1, "model":"Mercedes-Benz", "year":2019, "rate":5, "country":"Germany"},
  36.         {"id": 2, "model":"Subaru", "year":2017, "rate":5, "country":"Japan"},
  37.         {"id": 3, "model":"Volkswagen", "year":2018, "rate":5, "country":"Germany"},
  38.         {"id": 4, "model":"Fiat", "year":2017, "rate":4, "country":"Italy"},
  39.         {"id": 5, "model":"BMW", "year":2019, "rate":5, "country":"Germany"}]
  40.  
  41.  
Advertisement
Add Comment
Please, Sign In to add comment