I have been working on the code for

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.
This commit is contained in:
Rebecca Hankey 2024-11-20 18:17:41 -05:00
parent e2ad9342df
commit 0e877d3fba
1 changed files with 32 additions and 5 deletions

View File

@ -15,19 +15,46 @@ TENS_NAMES = [
]
def int_under_1000000_to_str(number):
return "umm..."
if number < 1000:
return int_under_1000_to_str(number)
else:
thousands, remainder = divide_with_remainder(number, 1000)
if remainder ==0:
return f"{int_under_1000_to_str(thousands)} thousand"
else:
return f"{int_under_1000_to_str(thousands)} thousand, {int_under_1000_to_str(remainder)}"
def int_under_1000_to_str(number):
return "umm..."
if number < 100:
return int_under_100_to_str(number)
else:
hundreds, remainder = divide_with_remainder(number, 100)
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)}"
def int_under_100_to_str(number):
return "umm..."
if number < 10:
return int_under_10_to_str(number)
elif number < 20:
return int_under_20_to_str(number)
else:
tens, ones = divide_with_remainder(number, 10)
if ones == 0:
return TENS_NAMES[tens]
else:
return f"{TENS_NAMES[tens]}-{int_under_10_to_str(ones)}"
def int_under_20_to_str(number):
return "umm..."
if number < 10:
return int_under_10_to_str(number)
else:
return TWEEN_AND_TEEN_NAMES[number - 10]
def int_under_10_to_str(number):
return "umm..."
return DIGIT_NAMES[number]
def divide_with_remainder(dividend, divisor):
"""Divides one number by another, using whole-number division.