[Tutor] Python 3.5 Question

Alan Gauld alan.gauld at btinternet.com
Fri Oct 9 11:26:52 CEST 2015


On 09/10/15 01:13, Sasuke Uchiha wrote:
> Hi, I would like to know how to create a code similar to the result below.
> I want to input a number like 1000, and for it to give me the maximum
> output with the least amount of bills (such as 100s)
>

This looks like homework and we won't do your homework for you.
But we can offer hints. It will help if you show us any
code you have written or even tell us how you think it might
work.

Meantime, look into the integer division and modulo operators.
They can be combined via the divmod() function which returns
both the division result and remainder in a single operation
like this:

hundreds,dollars = divmod(1737,100)

and hundreds will equal 17 and dollars 37.

hopefully you can see how that can be applied to your problem.
If not come back and ask more.

>     >>>
>     Please enter the amount of money you wish to withdraw: 1737 You received:
>     17 hundreds.
>     0 fifties.
>     1 twenties.
>     1 tens.
>     1 fives.
>     2 ones.

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos




More information about the Tutor mailing list