Answer :
The Python program that models two vehicles (Car and Truck) and simulates driving and refueling them during the summer is given below.
```python
class Vehicle:
def __init__(self, fuel_quantity, liters_per_km):
self.fuel_quantity = fuel_quantity
self.liters_per_km = liters_per_km
def drive(self, distance, is_summer=False):
if is_summer:
self.fuel_quantity -= distance * (self.liters_per_km + 0.9)
else:
self.fuel_quantity -= distance * self.liters_per_km
return distance if self.fuel_quantity >= 0 else 0
def refuel(self, liters):
self.fuel_quantity += liters
class Car(Vehicle):
def refuel(self, liters):
self.fuel_quantity += liters
class Truck(Vehicle):
def refuel(self, liters):
self.fuel_quantity += 0.95 * liters
car_info = input().split()
car = Car(float(car_info[1]), float(car_info[2]))
truck_info = input().split()
truck = Truck(float(truck_info[1]), float(truck_info[2]))
n = int(input())
for _ in range(n):
command = input().split()
action = command[0]
vehicle = command[1]
if action == "Drive":
distance = float(command[2])
if vehicle == "Car":
distance_covered = car.drive(distance, is_summer=True)
if distance_covered > 0:
print(f"Car travelled {distance_covered:.2f} km")
else:
print("Car needs refueling")
elif vehicle == "Truck":
distance_covered = truck.drive(distance, is_summer=True)
if distance_covered > 0:
print(f"Truck travelled {distance_covered:.2f} km")
else:
print("Truck needs refueling")
elif action == "Refuel":
liters = float(command[2])
if vehicle == "Car":
car.refuel(liters)
elif vehicle == "Truck":
truck.refuel(liters)
print(f"Car: {car.fuel_quantity:.2f}")
print(f"Truck: {truck.fuel_quantity:.2f}")
```
This program models the Car and Truck, simulates driving in the summer, and handles refueling. It calculates and prints whether the vehicles can travel a given distance and their remaining fuel quantities as per the specified requirements.
For more such questions on Python program
https://brainly.com/question/27996357
#SPJ4