Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Hello I need help with a very simple coding question (Python in particular) !! Our input can be any amount of change to give in
Hello I need help with a very simple coding question (Python in particular) !!
Our input can be any amount of change to give in dollars
Our output has to be the number of bills (twenties, tens, fives, and ones) that will be given back depending of the input.
We are required to use the integer operator (//) and the modulo operator (%)
If anyone can help me please let me know!!
1e Here we will be able to input the dollar amount of change needed. 11 amount_to_change = int(input("Enter change for:")) In [12]: runfile('C:/Users/cathr/Documents/Python Scripts/computingChange.py", wdir='c:/ Users/cathr/Documents/Python Scripts) 2 13 These will be used in determining the number of bills for each given variable 14 num_twenties = amount_to_change // 20 15 num_tens = amount_to_change // 10 16 num_fives = amount_to_change // 5 17 num_ones = amount_to_change // 1 Enter change for: 18 Change for $ 18 twenty dollar bill(s) and 1 ten dollar bill(s) z five dollar bill(s) and 19 one dollar bill(s) 18 In [13]: runfile('C:/Users/cathr/Documents/Python Scripts/computingchange.py", wdir='C:/ Users/cathr/Documents/Python Scripts') 194 This will print out the number of bills needed to give change 2print('Change for $', amount to change) 21 print(num_twenties, 'twenty dollar bill(s) and', num tens, 'ten dollar bill(s)') 22print(num_fives, 'five dollar bill(s) and', num ones, 'one dollar bill(s)') Enter change for: 5 Change for $ 5 twenty dollar bill(s) and @ ten dollar bill(s) 1 five dollar bill(s) and 5 one dollar bill(s) 25 In [14]: runfile('C:/Users/cathr/Documents/Python Scripts/computingchange.py', wdir='C:/ Users/cathr/Documents/Python Scripts') Enter change for: 1 Change for $1 e twenty dollar bill(s) and a ten dollar bill(s) five dollar bill(s) and 1 one dollar bill(s) In [15]Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started