Write a python program to calculate parking charges of a vehicle. Enter the type of vehicle as a character (like c for car, b for bus, etc.) and number of hours, then calculate charges as given below: Truck/bus - 20 per hour Car - 10 per hour Scooter/ Cycle/ Motor cycle-5 per hour
Answers
vehicle = int(input())
hours = int(input())
if vehicle == "t" or vehicle == "b":
print(hours * 20)
elif vehicle == "c" :
print(hours * 10)
elif vehicle == "s" or vehicle == "m":
print(hours * 5)
else:
print("Wrong choice")
- We took vehicle name as input and hours too.
- Then we built a conditional framework using if-elif-else statements.
- There is a statement in else block that prints wrong choice if none of the choice is met.
I hope that my answer helps you...
Answer:
vehicle=input("Enter s for 2-wheeler; c for 4-wheeler and b for bus/truck")
hours=int(input("Enter the number of hours in which the vehicle was parked"))
if vehicle=="s":
if hours<=3:
print("Total price for 2-wheeler is", (hours*20))
else:
total=hours-3
price=60+total*30
print("Total price for 2-wheeler is", price)
elif vehicle=="c":
if hours<=3:
price=hours*40
print("Total price for 4-wheeler is", price)
else:
total=hours-3
price=120+total*50
print("Total price for 4-wheeler is", price)
elif vehicle=="b":
if hours<=3:
price=hours*70
print("Total price for bus/truck is", price)
else:
total=hours-3
price=210+total*80
print("Total price for bus/truck is", price)
else:
print("Wrong choice")
Explanation:
the price for parking upto 3 hours is different from the rest