Answer to Question #201106 in Electrical Engineering for sarah

Question #201106

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%


1
Expert's answer
2021-05-31T11:34:27-0400
#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}")




Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS