Write a Python program to calculate the revenue from a sale based on the unit price and quantity of a product input by the user

  • برمجة بايثون

Write a Python program to calculate the revenue from a sale based on the unit price and quantity of a product input by the user.

The discount rate is 10% for the quantity purchased between 100 and 120 units, and 15% for the quantity purchased greater than 120 units. If the quantity purchased is less than 100 units, the discount rate is 0%. See the example output as shown below.

 

 

Example:

--------------

Input:

Enter unit price: 25

Enter quantity: 110

Output:

The revenue from sale: 2475.0$

الأجوبة

unitprice=int(input("Enter unit price:"))
quantity=int(input("Enter quantity:"))
if quantity>=100 and quantity<=120:
    TotalPrice=float(unitprice*quantity*0.9)
elif quantity>120:
    TotalPrice=float(unitprice*quantity*0.85)
else:
    TotalPrice=float(unitprice*quantity)
print("The revenue from sale: ",TotalPrice,"$")
هل كان المحتوى مفيد؟

تبحث عن مدرس اونلاين؟

محتاج مساعدة باختيار المدرس الافضل؟ تواصل مع فريقنا الان لمساعدتك بتأمين افضل مدرس
ماهو التخصص الذي تبحث عنه؟
اكتب هنا...