CBSE Class 11 Computer Science Question 125 of 161

Flow of Control — Question 2

Back to all questions
2
Question

Question 2

A store charges ₹120 per item if you buy less than 10 items. If you buy between 10 and 99 items, the cost is ₹100 per item. If you buy 100 or more items, the cost is ₹70 per item. Write a program that asks the user how many items they are buying and prints the total cost.

Solution
n = int(input("Enter number of items: "))

cost = 0

if n >= 100 :
    cost = n * 70
elif n >= 10 :
    cost = n * 100
else :
    cost = n * 120

print("Total Cost =", cost)
Output
Enter number of items: 58
Total Cost = 5800
Answer