Write a Python program to input the Username, City, Pricel and Price2. Find the average price. Display the output based on the following conditions as shown below. condition Discount Average between 999 and 2000 Average between 2000 and 5000 Otherwise 2.5% 3% 5%
#input the Username, City, Pricel and Price2
username=input("Username: ")
city=input("City: ")
pricel=float(input("Price 1: "))
price2=float(input("Price 2: "))
#Find the average price.
pricesSum=(pricel+price2)
averagePrice=pricesSum/2
#Display the output based on the following conditions as shown below.
#Condition Discount
#Average between 999 and 2000 2.5%
discount=0
print(f"The average price: {averagePrice}")
if averagePrice>=999 and averagePrice<2000:
discount=averagePrice*0.025
#Average between 2000 and 5000 3%
elif averagePrice>=2000 and averagePrice<5000:
discount=averagePrice*0.03
#Otherwise 5%
else:
discount=averagePrice*0.05
averagePrice-=discount
print(f"The discount: {discount}")
print(f"Total price: {averagePrice}")
Comments
Leave a comment