Ask Question
19 January, 11:36

A store sells widgets at 25 cents each for small orders or at 20 cents each for orders of 100 or more. Write a program that requests the number of widgets ordered and displays the total cost. (write the python program and after confirming it works, copy and paste the program code below)

+4
Answers (1)
  1. 19 January, 13:53
    0
    widgets=float (input ("Enter number of widgets you want to buy"))

    if widgets<0:

    print ("Can't compute negative number")

    else:

    if widgets<100:

    cost=widgets*25

    else:

    cost=widgets*20

    print ("The total cost of widgets is", cost,"cents")

    Explanation:

    First I made a variable called widgets to take input of the number of widgets the customer wants to buy. I use the first comditional statement to test if the number of items typed in is not less than zero.

    The else statement computed the prices of widgets based on number of widgets greater than zero.

    Another conditional statement to check if the widgets is lower that 100 or greater. The cost represents the total amount, in terms of cost it will take for some nuber of widgets.

    The last line prints the total cost and some statments
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “A store sells widgets at 25 cents each for small orders or at 20 cents each for orders of 100 or more. Write a program that requests the ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers