[Tutor] Help with simple coding

dn PyTutor at DancesWithMice.info
Fri Aug 14 20:02:25 EDT 2020

```On 15/08/2020 03:33, Marshall Jones wrote:
> Hiya,
>
> Spent hours on this, but seem to be getting further from getting it right.

Define "right"!

In another current list-conversation "Python programming question
related to Return/Print statement", I've suggested:
<<<
It might help (us, to help you) to include (the core of) the
course-assignment with a question. Looking at the sample data,...

BTW there is no crime/embarrassment in mentioning that it is a
course-assignment. We're happy to help introduce you/others to Python,
learning-progress!
>>>

In this case, an unanswered query relates to the second input() - does
this limit which denomination of coins we are 'allowed' to use, or what?
(it will be totally ignored for the rest of this discussion)

> money = int(input("how much money would you like to change into coins?"))
> coins = input("what coins do you want them in")
> pounds = (money // 1)
> fifty = (money // 0.5)
> twenties = (money // 0.2)
> tens = (money // 0.1)
> fives = (money // 0.02)
> twos = (money // 0.05)
> ones = (money // 0.001)
> if coins == pounds:
>      print (pounds)
>
> and then the same for fifty, twenties etc

The way to solve any problem is to break the 'large problem' down into
'small problems', and those into ever smaller problems, until the size
of the problem is easy for us to solve.
(ComSc term: "Stepwise Decomposition")

So, imagine you were doing this at your desk or a bank teller's counter.
You seem to have the right idea: Step one is to take the amount (to be
changed) and calculate how many one-pound notes it will require.

Let's use a random amount as an example: £1.23
How many notes? 1.23 // 1 -> 1.
Wow!

Now, next problem: how many 50p coins?
Do we use the original £1.23-amount in this calculation?
Thus, the next 'problem' is how much do we input into the second (50p)
calculation?
...and assuming you've spotted the needed correction, we continue 'down'
the list of coins.

After a while you'll realise that the 'problem' being solved is
virtually repeating itself - the only parts that are changing are the
amount-left and the coin-denomination.

If you've covered loops and collections, eg lists and/or tuples, then
I'll say no more. If you haven't, then these might be included in the
next lesson (and assignment)...
--
Regards =dn
```