Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- cars = {}
- n = int(input())
- for _ in range(n):
- line = input()
- line_split = line.split("|")
- car_brand = line_split[0]
- mileage = int(line_split[1])
- fuel = int(line_split[2])
- cars[car_brand] = {"mileage": mileage, "fuel": fuel}
- while True:
- data = input()
- if data == "Stop":
- break
- data_split = data.split(" : ")
- command = data_split[0]
- car_brand = data_split[1]
- if command == "Drive":
- distance = int(data_split[2])
- needed_fuel = int(data_split[3])
- if cars[car_brand]["fuel"] > needed_fuel:
- cars[car_brand]["mileage"] += distance
- cars[car_brand]["fuel"] -= needed_fuel
- print(f"{car_brand} driven for {distance} kilometers. {needed_fuel} liters of fuel consumed.")
- else:
- print(f"Not enough fuel to make that ride")
- if cars[car_brand]["mileage"] >= 100000:
- del cars[car_brand]
- print(f"Time to sell the {car_brand}!")
- elif command == "Refuel":
- current_fuel = int(data_split[2])
- additional_fuel = 75 - cars[car_brand]["fuel"]
- cars[car_brand]["fuel"] += min(current_fuel, additional_fuel)
- print(f"{car_brand} refueled with {min(current_fuel, additional_fuel)} liters")
- else:
- kilometers = int(data_split[2])
- cars[car_brand]["mileage"] -= kilometers
- if cars[car_brand]["mileage"] >= 10000:
- print(f"{car_brand} mileage decreased by {kilometers} kilometers")
- else:
- cars[car_brand]["mileage"] = 10000
- for car_brand, value in cars.items():
- print(f"{car_brand} -> Mileage: {cars[car_brand]['mileage']} kms, Fuel in the tank: {cars[car_brand]['fuel']} lt.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement