1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
LekaFEV [45]
3 years ago
11

Write a Python program to: ask the user to enter the price of an item. Note: use a while loop to check the validity of the price

and, if the user enters a price less than or equal to zero, to prompt for a valid price. Prompt the user for the quantity being purchased. If the quantity is ten or greater, apply a discount of 5 percent. (.95*price*quantity).
Computers and Technology
1 answer:
garik1379 [7]3 years ago
3 0

Answer:

Hi there Tonyhh! Please find the implementation below.

Explanation:

You can save the below code in a file called "price_discount.py". The code is implemented in python 2.0+. To make it work in Python 3.0+, simply update the code to use "input" rather than "raw_input".

price_discount.py

def calculate_discount(price, quantity):

 total = 0.95 * price * quantity;

 return total;

price = raw_input("Enter a price: ");

try:

 price = int(price);

 while price <= 0:

   print("Input a valid number: ")

   price = raw_input("Enter a price: ");

 quantity = raw_input("Enter a quantity: ");

 try:

   quantity = int(quantity);

   if quantity >= 10:

     print(calculate_discount(price, quantity));

 except ValueError:

   print("Invalid quantity!")

except ValueError:

 print("Invalid input!");

 price = -1;

You might be interested in
The encapsulation unit on the presentation layer of the osi model is
Zielflug [23.3K]
<span>The encapsulation unit on the presentation layer of the OSI model is the Data link layer (2).</span>
7 0
4 years ago
Which of these is NOT a benefit of trade?
Natasha_Volkova [10]

Answer:

<em>Creation of Dependencies</em> is not the only benefit of trade in the list.

Explanation:

People can provide the access to their resource with the help of trading, it will also increase the satisfaction of customer as he will be able to buy the product of his own choice with satisfactory price, as it breaks the monopoly of local producers.

There many disadvantages of the trade, such as it will create dependencies on other countries and local producers not be able to produce that products, this will lead to increase in imports and will increase the trade deficit of the country.

8 0
4 years ago
What does mean I can’t turn on my computer and my computer won’t charge at all
Dmitrij [34]

Explanation:

well that happened to me to and what my dad did was to cut the cable and fix it,it worked.Ithink my situation is very different than yours but you cantiue to see what else it says and if you want to you can text me back.

5 0
3 years ago
Web pages often have built-in connections, or links, to other documents, graphics, other web pages, or web sites. true or false?
yawa3891 [41]
Web pages often have built-in connections, or links, to other documents, graphics, other web pages, or web sites.

true
7 0
3 years ago
John wants to use graphical elements on his web page. Which image formats should he use to keep the file size manageable?
asambeis [7]

Answer:

PNG, GIF

Explanation:

On a Web page, we'll assume he'll have simple graphic elements like icons, or other simple low-resolution and a lower number of colors (256-), these are usually better saved in GIF format to take less space, just because of the smaller color map, but PNG could also do a great job and  it offers transparency as well (like GIF does).

For more complex elements (larger size and/o more colors like photos), the best format to save them is probably the PNG one.  They will be compressed but still offer a great quality.

7 0
4 years ago
Other questions:
  • How have computers changed overtime
    13·2 answers
  • A device that produces a permanent human-readable text of graphic document.
    15·1 answer
  • Why would it be a bad idea for gateways to pass broadcast packets between networks? What would be the advantages of doing so
    12·1 answer
  • TP is commonly used to __________ and __________ files to a server.
    5·1 answer
  • IN YOUR OWN WORDS, create a new thread and compare and contrast paraphrasing, summarizing, and quoting and how to do each succes
    14·1 answer
  • Question 19 :Rachel, a database administrator, has created a database for her website. It contains pictures of vacations that pe
    13·1 answer
  • Trevor owns a manufacturing business that makes specialized hiking and rock climbing gear. He is a very small player in the mark
    8·1 answer
  • You enjoy helping people find solutions to problems that they are having with technology. Which job might be best for you?
    6·1 answer
  • Is a way og saving a file so it can be used by a different program​
    11·1 answer
  • Is the following statement valid or invalid? y + 1 = 6​
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!