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 should I make to the PYTHON program above so that it is clear that the values are all printed in pounds?

0 0
Add a comment Improve this question Transcribed image text
Answer #1

In print statement include parentheses

-----------------------------------------------------------------------------------

#Assumed that entered prices are in pounds
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,"pounds")


-----------------------------------------------------------------------

#Assumed that entered prices are in Indian rupie
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*0.011,"pounds")


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 would you make to the PYTHON program above so that it is clear that the values are all 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...

  • 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...

  • 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...

  • Write a python program that runs only on the command-line prompt. i.e. if you run this...

    Write a python program that runs only on the command-line prompt. i.e. if you run this program on IDEL it would give you an error message. Name the program “buy.py.” Assume that this program is used by a departmental store to calculate your total price if you want to buy an extended warranty for your purchased Computer. The program takes two arguments at the command-line prompt: 1) the computer’s brand name, and 2) the price of the computer that you...

  • Hello! I'm looking for help with this assignment. Complete a program in pseudocode and Python that...

    Hello! I'm looking for help with this assignment. Complete a program in pseudocode and Python that performs the following tasks. Open the file called M4Lab1ii.py linked below these instructions in your M4 Content module in IDLE. Save as M4Lab1ii.py. Replace ii with your initials. [example for someone with the initials cc: M4Lab1cc.py] Complete Steps 1-7 as requested within the code’s comments. Run your program and test all four calculations, then exit the program. Save your program as M4Lab1ii.py using your...

  • 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