Question

Suppose the PYTHON program below is run on your computer: expenses = 0 while True: answer...

Suppose the PYTHON program below is run on your computer:

expenses = 0

while True:

answer = input("Give the price of the next item ordered?")

if answer == "end":

break

else:

price = float(answer)

expenses = expenses + price

print "Total value of orders is:", expenses

What changes would you make to the PYTHON program above so that it is clear that the values are all in pounds?

0 0
Add a comment Improve this question Transcribed image text
Answer #1
#Approach 1
#Ask user to enter amount in pounds
expenses = 0
while True:
    #We have to ask user to enter amount in pounds
    answer = input("Give the price of the next item ordered in pounds?")
    if answer == "end":
        break
    else:
        price = float(answer)
    expenses = expenses + price

print("Total value of orders is:", expenses)

===================================

#Approach 2
#Ask user to enter amount in dollars and cnvert the final amount to pounds
expenses = 0
while True:
    #We have to ask user to enter amount in pounds
    answer = input("Give the price of the next item ordered in pounds?")
    if answer == "end":
        break
    else:
        price = float(answer)
    expenses = expenses + price

print("Total value of orders is:", (expenses*0.76))

Add a comment
Know the answer?
Add Answer to:
Suppose the PYTHON program below is run on your computer: expenses = 0 while True: answer...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Suppose the PYTHON program below is run on your computer: expenses = 0 while True: answer...

    Suppose the PYTHON program below is run on your computer: expenses = 0 while True: answer = input("Give the price of the next item ordered?") if answer == "end": break else: price = float(answer) expenses = expenses + price print "Total value of orders is:", expenses What changes should I make to the PYTHON program above so that it is clear that the values are all printed in pounds?

  • Can you please enter this python program code into an IPO Chart? import random def menu():...

    Can you please enter this python program code into an IPO Chart? import random def menu(): print("\n\n1. You guess the number\n2. You type a number and see if the computer can guess it\n3. Exit") while True: #using try-except for the choice will handle the non-numbers #if user enters letters, then except will show the message, Numbers only! try: c=int(input("Enter your choice: ")) if(c>=1 and c<=3): return c else: print("Enter number between 1 and 3 inclusive.") except: #print exception print("Numbers Only!")...

  • Python: def combo(): play = True while play: x = int(input('How many people\'s information would you...

    Python: def combo(): play = True while play: x = int(input('How many people\'s information would you like to see: ')) print()    for num in range(x): name() age() hobby() job() phone() print()       answer = input("Would you like to try again?(Enter Yes or No): ").lower()    while True: if answer == 'yes': play = True break elif answer == 'no': play = False break else: answer = input('Incorrect option. Type "YES" to try again or "NO" to leave": ').lower()...

  • USE PYTHON 3, RUN THE CODE BEFORE POSTING THE ANSWER, AND READ THE ASSIGNMENT REQUIREMENTS NOTE CAREFULLY: Assignment...

    USE PYTHON 3, RUN THE CODE BEFORE POSTING THE ANSWER, AND READ THE ASSIGNMENT REQUIREMENTS NOTE CAREFULLY: Assignment Requirements NOTE: This program requires the use of if, elif, else, and casting between strings and numbers. The program should use the various code syntax covered in module 3. The program must result in print output using numeric input similar to that shown in the sample output below. Program: Cheese Order set values for maximum and minimum order variables set value for...

  • . Use what you learned from our First Python Program to write a Python program that...

    . Use what you learned from our First Python Program to write a Python program that will carry out the following tasks. Ask user provide the following information: unit price (for example: 2.5) quantity (for example: 4) Use the following formula to calculate the revenue: revenue = unit price x quantity Print the result in the following format on the console: The revenue is $___. (for example: The revenue is $10.0.) . . Use the following formula to calculate the...

  • Can you add code comments where required throughout this Python Program, Guess My Number Program, and...

    Can you add code comments where required throughout this Python Program, Guess My Number Program, and describe this program as if you were presenting it to the class. What it does and everything step by step. import random def menu(): #function for getting the user input on what he wants to do print("\n\n1. You guess the number\n2. You type a number and see if the computer can guess it\n3. Exit") while True: #using try-except for the choice will handle the...

  • This Python program will need to include the following items listed below. You are to customize your program and create the sequence in any order of your choice. Must include Python comments for each...

    This Python program will need to include the following items listed below. You are to customize your program and create the sequence in any order of your choice. Must include Python comments for each of the items shown below. Calculate a Percentage. For example, the discount percentage on a sale item. Use of 3 Constants. To be used for values that will not change throughout the life of the program. A Turtle Graphic Logo. This logo will be used to...

  • Using python, write code for problem. Please also put screenshot of your code. The following program...

    Using python, write code for problem. Please also put screenshot of your code. The following program will perform properly if the user enters 0 in response to the request for input. However, the program will crash if the user responds with "eight". Rewrite the program using a try/except statement so that it will handle both types of responses. See Fig. 6.1. while True: n = int (input ("Enter a nonzero integer: ")) if n! = 0: reciprocal = 1/n print...

  • Part 1: Python code; rewrite this code in C#, run the program and submit - include...

    Part 1: Python code; rewrite this code in C#, run the program and submit - include comments number= 4 guesscount=0 guess=int(input("Guess a number between 1 and 10: ")) while guess!=number: guesscount=guesscount+1 if guess<number: print("Your guess is too low") elif guess>number: print("Your guess is too high") else: print("You got it!!") guess=int(input("Guess again: ")) print("You figured it out in ",guesscount," guesses") Part 2: C++ code; rewrite the following code in C#. Run the program and submit. - include comments #include <iostream> using...

  • I'm making a To-Do list in Python 2 and had the program running before remembering that...

    I'm making a To-Do list in Python 2 and had the program running before remembering that my professor wants me to put everything in procedures. I can't seem to get it to work the way I have it now and I can't figure it out. I commented out the lines that was originally in the working program and added procedures to the top. I've attached a screenshot of the error & pasted the code below. 1 todo_list = [] 2...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT