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$

الأجوبة

price=float(input("Enter price: "))
qty=float(input("Enter quantity: "))

revenue=price*qty
if revenue < 100:
    discount=revenue;
elif (100< revenue < 120):
    discount=revenue*10/100
elif revenue > 120:
    discount=revenue*15/100;
  
net_rev=revenue-discount

print("The revenue from sale: ",revenue,"$")
هل كان المحتوى مفيد؟

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

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