My question is posted in the photos and what I have is also a photo attachment. I need a basic python code that uses //, % and / and can compute the “ACTUAL OUTPUT” Do not need a complex code

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
My question is posted in the photos and what I have is also a photo attachment. I need a basic python code that uses //, % and / and can compute the “ACTUAL OUTPUT” Do not need a complex code
Expert Solution
Step 1

program:-

import sys
#taking input
TotalAmount=input("Enter total cost of purchase: ") 
GivenCash=input("Enter Amount paid: ")
TotalAmount=round(float(TotalAmount),2)
GivenCash=round(float(GivenCash),2)
if float(TotalAmount)>float(GivenCash):
        sys.exit("Did not receive enough cash from the customer.")
#spliting money into bills and coins 
TotalBills,TotalCoins=map(int,str(TotalAmount).split("."))
GivenBills,GivenCoins=map(int,str(GivenCash).split("."))
#get the actual amount which needs to be break down into bills and coins
TotalBills=GivenBills-TotalBills
TotalCoins=GivenCoins-TotalCoins
#if there are no enough 
if TotalCoins<0:
        TotalCoins=100+TotalCoins #used plus because Total coins is in negitive value
        TotalBills-=1
#stored bill and coin amounts
bills=[20,10,5,1]
coins=[25,10,5,1]
#to store number of bills and coins
ReturnBills=[0,0,0,0]
ReturnCoins=[0,0,0,0]
'''
for first loop it divided Total bills with 20(it is at first index)
adds that to returnbills[0]
then TotalBills=TotalBills%bills[i] places the remaninder when 20 is divide total amount
this is repeated for all bills
same for coins too
'''
for i in range(4):
        ReturnBills[i]=TotalBills//bills[i] 
        TotalBills=TotalBills%bills[i]
        ReturnCoins[i]=TotalCoins//coins[i]
        TotalCoins=TotalCoins%coins[i]
#printing
print("Please to return")
if ReturnBills[0]>0:
        print(ReturnBills[0]," twenties bills")
if ReturnBills[1]>0:
        print(ReturnBills[1]," tens bills")
if ReturnBills[2]>0:
        print(ReturnBills[2]," fives bills")
if ReturnBills[3]>0:
        print(ReturnBills[3]," ones bills")
if ReturnCoins[0]>0:
        print(ReturnCoins[0]," quarters")
if ReturnCoins[1]>0:
        print(ReturnCoins[1]," dimes")
if ReturnCoins[2]>0:
        print(ReturnCoins[2]," nickels")
if ReturnCoins[3]>0:
        print(ReturnCoins[3]," pennies")

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Top down approach design
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
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