Files
problemset_numberwords/planning_1st_try.md
kathrynoh23 401162aac3 Kathryn Odell-Hamilton
2023.9.13

I understand the Data Types within "Number Words" from learning and
teaching Java.

The planning.md was straight forward. Was my return for each function
correct? Am I to used " " for the string of text.

Within some of your discussions in Discord, you had mention to checkout
using ChatGPT. I wouldn't sign on to ChatGPT because it wanted your
phone number. Instead, I used Bing Chat after signing into my
Microsoft account. Wow!!! I found it interesting with the extensive
explanation of information it provides to solve a problem. I didn't
use it for the answers. AI is very scary if not used in a
responsible manner.

Yes, the numberwords.py had all the answers, but I found it
valuable because of how you wrote out the digit numbers for the "else"
and "return". In do understand this.

The test_numberwords.py file completely passed with the test_cases.
2023-09-12 13:13:36 -04:00

85 lines
2.5 KiB
Markdown

# Planning Number Words
Before you start programming, do some planning here on how you will break down
this problem. Here's a hint: if you start by writing functions for smaller numbers,
you will find that these functions help you with the larger numbers. For each of
the cases below, explain how you would turn a number into a string. Feel free to
write in sentences or in pseudocode (pseudocode is a sort of "casual programming"
where you're almost writing in code, being pretty specific without worrying about
syntax. For each case below, assume the integer is zero or more--don't worry about
negative integers.
## Integers under 10
(This one is done for you!)
For an integer less than ten, you need to know the name of each digit, and look it
up. You could use a big if/else statement like:
```
if number == 0:
return "zero"
elif number == 1:
return "one"
elif number == 1:
return "two"
```
A cleaner way to do this would be to make a list of digit names, from zero to nine.
Then you could just look up a digit's name:
```
digit_names = [
"zero", "one", "two", "three", "four",
"five", "six", "seven", "eight", "nine"
]
return digit_names[number]
```
## Integers under 20
If the integer is under 10, then use the procedure described above.
Otherwise, ... (this is where you take over!)
# Define the integer to string
# Could use if else
# elif should be returned to "zero" or "Number is greater than or equal to 20."
# ??Not sure
def int_under_20_to_str(number):
if number <20:
return str(number)
elif number >= 20:
return "Number is greater than or equal to 20."
## Integers under 100
def int_under_100_to_str(number):
if number < 100:
return str(number)
elif number >= 100:
return "Number is greater than or equal to 100."
## Integers under 1000
def int_under_1000_to_str(number):
if number < 1000:
return str(number)
elif number >= 100:
return "Number is greater than or equal to 1000."
## Integers under 1000000
def int_under_1000000_to_str(number):
if number < 1000000:
return str(number)
elif number >= 100:
return "Number is greater than or equal to 100."
## Negative integers down to -1 million
We won't deal with negative integers in this problem set,
but how would you deal with a negative integer, using the
functions above?
# You can use the negative integer range from -1 to -1000000
if number < 0:
if number > -1000000:
elif number >= 0:
elif number >= 1000000:
# Is this what you are looking for coding the define functions?