In Python with only variables, arithmetic operators, and conditionals (No while, No for, No List) can you: Design and implement program that writes out what bills and coins would be dispensed if this machine existed for the amount of money that was entered. The money dispenser should be grammatically correct. One of the most challenging parts of the float is a result of the imprecision of floating point numbers. Avoid this issue by converting the value that is entered in the keyboard into an integer. For example, if 123.45 (the amount in dollars) is entered into the keyboard, you should convert it to 12345 (the amount in cents). This is common practice when dealing with dollar amounts when it does make sense to have parts of a cent. The behavior of round() for floats can be surprising: for example, round(2.675, 2) gives 2.67 instead of the expected 2.68. This is not a bug: it’s a result of the fact that most decimal fractions can’t be represented exactly as a float. To avoid this issue, you should use integers instead of floats. Ex: Enter amount: 123.45 6 twenties 3 ones 1 quarter 2 dimes
In Python with only variables, arithmetic operators, and conditionals (No while, No for, No List) can you:
Design and implement program that writes out what bills and coins would be dispensed if this machine existed for the amount of money that was entered. The money dispenser should be grammatically correct.
One of the most challenging parts of the float is a result of the imprecision of floating point numbers. Avoid this issue by converting the value that is entered in the keyboard into an integer. For example, if 123.45 (the amount in dollars) is entered into the keyboard, you should convert it to 12345 (the amount in cents). This is common practice when dealing with dollar amounts when it does make sense to have parts of a cent.
The behavior of round() for floats can be surprising: for example, round(2.675, 2) gives 2.67 instead of the expected 2.68. This is not a bug: it’s a result of the fact that most decimal fractions can’t be represented exactly as a float. To avoid this issue, you should use integers instead of floats.
Ex:
Enter amount: 123.45
6 twenties
3 ones
1 quarter
2 dimes
![](/static/compass_v2/shared-icons/check-mark.png)
amt=float(input("Enter the amount:"))
amt=amt*100
print(int(amt//2000),"twenties")#to find twenties
amt=amt%2000#to calculate remaining amount after removing twenties
print(int(amt//1000),"tens")#to find tens
amt=amt%1000#to find remaining amount after removing twenties, tens
print(int(amt//500),"fives")# to find fives
amt=amt%500#to find remaining amount after removing twenties, tens, fives
print(int(amt//100),"Ones")#to find ones
amt=amt%100#to find remaining amount after removing tens,twenties,tens,fives
print(int(amt//25),"quaters")#to find quaters
amt=amt%25#to find remaining amount after removing tens,twenties,tens,fives,quaters
print(int(amt//10),"dimes")#to find dimes
amt=amt%10#to find remaining amount after removing tens,twenties,tens,fives,quaters,dimes
print(int(amt//5),"nickels")#to find nickels
amt=amt%5#to find remaining amount after removing tens,twenties,tens,fives,quaters,dimes,nickels
print(int(amt),"pennies")# to print remaining ones which are pennies
Step by step
Solved in 3 steps with 2 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Concepts of Database Management](https://www.bartleby.com/isbn_cover_images/9781337093422/9781337093422_smallCoverImage.gif)
![Prelude to Programming](https://www.bartleby.com/isbn_cover_images/9780133750423/9780133750423_smallCoverImage.jpg)
![Sc Business Data Communications and Networking, T…](https://www.bartleby.com/isbn_cover_images/9781119368830/9781119368830_smallCoverImage.gif)