assignment by defining the code for digits, tens, teens, hundered, thousands, then
numbers under 1,000,000.
This process was challenging, but it felt like the key to this problem solving
was looking for patterns. I really liked the planning stage and saying the numbers outloud as
a planning strategy. Once the groups were established, then the patterns were a copy and adjust process.
I ran the test function frequently.
Starting from the bottom I did the easiest definition first, with the digits, then worked my way up thorugh the
other definitions. The most difficult part was figuring out the exceptions to the "if then"
statements. I knew what the if then statements should return, but the expections were a trial
and error process. For example:
if remainder == 0:
return f"{int_under_10_to_str(hundreds)} hundred"
else:
return f"{int_under_10_to_str(hundreds)} hundred and {int_under_100_to_str(remainder)}"
I understood that if the remainder was nothing then the word that it should produce was hunderd. Since
we were calling for the end of the whole number in the hundreds. However, of course, there
are numbers in the hundreds that do not end in that word, since the other digits create other numbers
like two hundred and fifty two. Fifty two needs to be read and converted into words. It made sense to divide
that hundred and find the remainder, but I was not sure how to have it then read the remainder as a number.
To troubleshoot this I wrote a lot of it on paper. I find myself resorting back to paper to plan.
I ran through the code and drew lines over the pieces in the same way I drew lines over the numbers when
I read them aloud in the planning phase.
Finally, I found myself getting the same error messages over and over. No matter what I
tweaked or adjusted, it was still saying that a couple of the numbers it tried to generate were incorrect.
So, I needed to change my approach. Instead of runnung the test function, I started running examples
to troubleshoot.
(problemset-numberwords-py3.12) rebeccahankey@Rebeccas-Air problemset_numberwords % python nw.py 123421
one hundred and twenty-three thousand and four hundred and twenty-one
(problemset-numberwords-py3.12) rebeccahankey@Rebeccas-Air problemset_numberwords % python nw.py 598567
five hundred and ninety-eight thousand and five hundred and sixty-seven
(problemset-numberwords-py3.12) rebeccahankey@Rebeccas-Air problemset_numberwords % python nw.py 87652 | say
(problemset-numberwords-py3.12) rebeccahankey@Rebeccas-Air problemset_numberwords % python nw.py 1001
one thousand and one
These worked! I even ran the numbers that the code referenced as being errors and they generated correctly!
It was a great feeling. I also have a Mac so I played with the say function a little which was
oddly gratifying.
numberwords. This assignment seemed really daunting at first, but it
appears to be following a fairly straight forward pattern
Planning from the top down gave me to chance to break elements into
groups where definitions and functions could be similar, but accomplish
different tasks. I have not gotten it to work competely, but I am in the phase
where the errors appear to by typos, rather than reworking the entire project.
That is reassuring, however I wanted to take the chance to submit once before
these typos are complete and corrected, because I remember with other assignments
getting through the typo-phase, then having the code still throw errors.
On a different note, I have found it difficult to remember to submit my work as
I go. I just find myself in a zone and I almost forget to come up for air.
Once I find a pattern that appears to do what I want it to, then I get buckled in and
focused on copying that pattern exactly. I find that when I step away or take a break to reflect that
I have an extremely tough time getting back into it. i wonder if that is beause I am
not as experienced in coding? So, the trasnition in and out of the process if jarring.
m so that numbers, when entered, would be written out in
words.
This process was easy at first, then became more challenging as the
numbers became larger. That sounds obvious and somewhat reductive, but it
is true. The digits are easy to understand. Numbers 1-9 need to be
defined and so you create a list and define them.
It also made sense to look for those same patterns that occur
in numbers. To group numbers with like numbers as the digits were grouped.
For example numbers that end in Teen or the Tens. It hepled to think of these
in two ways. The first step I took was to write a number in the
millions, read it out loud, then start dividing it into pieces based off of what I said.
As I did this I thought it might be a fun way to think about top-down planning.
If you gave students a receipe or number and had them read it out loud and based on
what you say create like-groups or steps, then think about how to implement them or
how onecould use similar solutions to tackle similar problems.