Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Week 1 - Exercise Notebook created by Jonathan Penava For this exercise you are going to write a function that makes change for amounts less

Week 1- Exercise
Notebook created by Jonathan Penava
For this exercise you are going to write a function that makes change for amounts less than one dollar. Input must be a positive integer up to 100, representing
an amount of money, in cents. Output must be the original amount of money together with a set of coins (quarters, dimes, nickels) that could make up the
amount. The function must produce change containing the minimum number of coins required to produce the given amount. Remember that the penny is no
longer in production, so you must round the value up or down accordingly. The output must be reasonable and non-stilted. For example, the input of 54
should produce results such as: 54 cents requires 2 quarters, 1 nickel rather than 54 cents requires 2 quarters, 0 dimes, 1 nickels
Provide some message if values do not produce output.
def makeChange(change) :
return ""Week 1- Exercise.ipynb > forms.html
Code + Markdown |-= Outline cdots
makeChange(68)
...'68 cents requires 2 quarters, 2 dimes'
makeChange(54)
[3]
Python
...'54 cents requires 2 quarters, 1 nickel'
makeChange(31)
[4]
Python
'31 cents requires 1 quarter, 1 nickel'
makeChange(18)
[5]
Python
'18 cents requires 2 dimes'Week 1- Exercise.ipynb
C: > Users > hp > Downloads > D Week 1- Exercise.ipynb > M Week 1- Exercise >m+ Notebook created by Jonathan Penava >
Code + Markdown |-= Outline ...
makeChange(82)
6
...'82 cents requires 3 quarters, 1 nickel'
makeChange(40)
[7]
...'40 cents requires 1 quarter, 1 dime, 1 nickel'
makeChange(99)
[8]
... 'Cannot make change.'
makeChange (-2)
[9]
... 'Cannot make change.'

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Understanding Databases Concepts And Practice

Authors: Suzanne W Dietrich

1st Edition

1119827949, 9781119827948

More Books

Students also viewed these Databases questions

Question

Why do some individuals confess to a crime they did not commit?

Answered: 1 week ago

Question

describe and present a summary of data you have collected.

Answered: 1 week ago

Question

collect, organise and store quantitative data in an effective way;

Answered: 1 week ago