How do I remove the 000000005 from the over budget when I run the program.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
How do I remove the 000000005 from the over budget when I run the program.
File Edit Format Run Options Window Help
2# Program Name: Lab 3
Author: Cory Morris.
Location: c:\python\
3# Date written: 9/16/2022
4# Created to fulfill requirments for CoSC 1336, Sec. 014, Fall 2022
5#------
Programe Summary: Enter number of packages purchased, get the Total Amount and Discount
#-------
# Data Dictionary
# Name: Enter number of packages purchased
10 =====
6
7 #--
11
12
13 #amount budgeted for the month
14
15 amountbudget = float (input ("Enter amount budgeted for the month: "))
16
17
18 a 1
19
20 total = 0.0
21
22 while a = 1:
23
24
25
26
27
28
29
b-float (input ("Enter an amount spent (0 to quit):"))
if (b== 0):
a = 0
else: total total + b
30
31 print ("amountbudget: $" + str (amountbudget))
32
33 print ("amountspent: $" + str (total))
34
String: Message String [AZ] [1-151]
35 if (amountbudget > total):
36
37
38
39 elif (amountbudget < total):
40
41
45
print("$" + str (amountbudget-total) +"under budget WELL DONE!")
print("s" + str (total- amountbudget) +"over budget PLAN BETTER NEXT TIME!, '.2f¹")
42
43 else: print ("The amount budget is the same as the amount spent WELL DONE!")
IDLE Shell 3.10.6
File Edit Shell Debug Options Window Help
amountbudget: $500.0
amountspent: $948.95
you are $448.95000000000005over budget PLAN BETTER NEXT TIME!
>>>
>>>
>>>
Enter amount budgeted for the month:500
Enter an amount spent (0 to quit):50
Enter an amount spent (0 to quit):75
Enter an amount spent (0 to quit): 800
Enter an amount spent (0 to quit):23.95
Enter an amount spent (0 to quit):0
amountbudget: $500.0
amountspent: $948.95
= RESTART: C:\Users\CoryM_h7vhvbi\AppData\Local\Programs\Python\Python310\Morris
lab4.py
$448.95000000000005over budget PLAN BETTER NEXT TIME!
= RESTART:
lab4.py
Def
Enter amount budgeted for the month:500
Enter an amount spent (0 to quit):50
Enter an amount spent (0 to quit):75
Enter an amount spent (0 to quit):822
Enter an amount spent (0 to quit):23.95
Enter an amount spent (0 to quit):0
amountbudget: $500.0
amountspent: $970.95
C:\Users\CoryM_h7vhvbi\AppData\Local\Programs\Python\Python310\Morris
Enter amount budgeted for the month:500
Enter an amount spent (0 to quit):50
Enter an amount spent (0 to quit):75
Enter an amount spent (0 to quit):800
Enter an amount spent (0 to quit):23.95
Enter an amount spent (0 to quit):0
Hal
amountbudget: $500.0
amountspent: $948.95
X
$470.95000000000005over budget PLAN BETTER NEXT TIME!,.2f
= RESTART: C:\Users\CoryM_h7vhvbi\AppData\Local\Programs\Python\Python310\Morris
lab4.py
$448.95000000000005over budget_ PLAN BETTER NEXT TIME!, '.2f'
Ln: 189 Col: 0
Transcribed Image Text:File Edit Format Run Options Window Help 2# Program Name: Lab 3 Author: Cory Morris. Location: c:\python\ 3# Date written: 9/16/2022 4# Created to fulfill requirments for CoSC 1336, Sec. 014, Fall 2022 5#------ Programe Summary: Enter number of packages purchased, get the Total Amount and Discount #------- # Data Dictionary # Name: Enter number of packages purchased 10 ===== 6 7 #-- 11 12 13 #amount budgeted for the month 14 15 amountbudget = float (input ("Enter amount budgeted for the month: ")) 16 17 18 a 1 19 20 total = 0.0 21 22 while a = 1: 23 24 25 26 27 28 29 b-float (input ("Enter an amount spent (0 to quit):")) if (b== 0): a = 0 else: total total + b 30 31 print ("amountbudget: $" + str (amountbudget)) 32 33 print ("amountspent: $" + str (total)) 34 String: Message String [AZ] [1-151] 35 if (amountbudget > total): 36 37 38 39 elif (amountbudget < total): 40 41 45 print("$" + str (amountbudget-total) +"under budget WELL DONE!") print("s" + str (total- amountbudget) +"over budget PLAN BETTER NEXT TIME!, '.2f¹") 42 43 else: print ("The amount budget is the same as the amount spent WELL DONE!") IDLE Shell 3.10.6 File Edit Shell Debug Options Window Help amountbudget: $500.0 amountspent: $948.95 you are $448.95000000000005over budget PLAN BETTER NEXT TIME! >>> >>> >>> Enter amount budgeted for the month:500 Enter an amount spent (0 to quit):50 Enter an amount spent (0 to quit):75 Enter an amount spent (0 to quit): 800 Enter an amount spent (0 to quit):23.95 Enter an amount spent (0 to quit):0 amountbudget: $500.0 amountspent: $948.95 = RESTART: C:\Users\CoryM_h7vhvbi\AppData\Local\Programs\Python\Python310\Morris lab4.py $448.95000000000005over budget PLAN BETTER NEXT TIME! = RESTART: lab4.py Def Enter amount budgeted for the month:500 Enter an amount spent (0 to quit):50 Enter an amount spent (0 to quit):75 Enter an amount spent (0 to quit):822 Enter an amount spent (0 to quit):23.95 Enter an amount spent (0 to quit):0 amountbudget: $500.0 amountspent: $970.95 C:\Users\CoryM_h7vhvbi\AppData\Local\Programs\Python\Python310\Morris Enter amount budgeted for the month:500 Enter an amount spent (0 to quit):50 Enter an amount spent (0 to quit):75 Enter an amount spent (0 to quit):800 Enter an amount spent (0 to quit):23.95 Enter an amount spent (0 to quit):0 Hal amountbudget: $500.0 amountspent: $948.95 X $470.95000000000005over budget PLAN BETTER NEXT TIME!,.2f = RESTART: C:\Users\CoryM_h7vhvbi\AppData\Local\Programs\Python\Python310\Morris lab4.py $448.95000000000005over budget_ PLAN BETTER NEXT TIME!, '.2f' Ln: 189 Col: 0
Expert Solution
Explanation

1) Below is your updated program which format the result string into 2 decimal places

2) It uses str.format() with “{:.2f}” as string and float as a number to display 2 decimal places in Python.

3) When called in print and it will display the float with 2 decimal places, so we can avoid 0000000005 from over budget and under budget messages.

  • see the bold section in program

4) save Program in python file and run

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Asymptotic Analysis
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education