Skip to content

Commit f640d96

Browse files
committed
resubmitting lab03
1 parent da16e11 commit f640d96

File tree

1 file changed

+152
-17
lines changed

1 file changed

+152
-17
lines changed

code/jonpan/lab03.py

Lines changed: 152 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,161 @@
1-
ones = {"1":"One","2":"Two","3":"Three","4":"Four","5":"Five","6":"Six", "7":"Seven","8":"Eight","9":"Nine","0":""}
2-
teens = {"10":"Ten","11":"Eleven","12":"Twelve","13":"Thirteen","14":"Fourteen","15":"Fifteen","16":"Sixteen", "17":"Seventeen","18":"Eighteen","19":"Nineteen"}
3-
tens = {"2":"Twenty","3":"Thirty","4":"Fourty","5":"Fifty","6":"Sixty", "7":"Seventy","8":"Eighty","9":"Ninety"}
4-
5-
x = input("\nInput a number from 0-99: ")
6-
tens_digit = int(x)//10
7-
teens_digit = int(x)
8-
ones_digit = int(x)%10
1+
#VERSION 1
2+
3+
# ones = {
4+
# "1":"One",
5+
# "2":"Two",
6+
# "3":"Three",
7+
# "4":"Four",
8+
# "5":"Five",
9+
# "6":"Six",
10+
# "7":"Seven",
11+
# "8":"Eight",
12+
# "9":"Nine",
13+
# "0":"Zero"
14+
# }
15+
# teens = {
16+
# "10":"Ten",
17+
# "11":"Eleven",
18+
# "12":"Twelve",
19+
# "13":"Thirteen",
20+
# "14":"Fourteen",
21+
# "15":"Fifteen",
22+
# "16":"Sixteen",
23+
# "17":"Seventeen",
24+
# "18":"Eighteen",
25+
# "19":"Nineteen"
26+
# }
27+
# tens = {
28+
# "2":"Twenty",
29+
# "3":"Thirty",
30+
# "4":"Fourty",
31+
# "5":"Fifty",
32+
# "6":"Sixty",
33+
# "7":"Seventy",
34+
# "8":"Eighty",
35+
# "9":"Ninety"
36+
# }
37+
38+
# x = input("\nInput a number from 0-99: ")
39+
# tens_digit = int(x) // 10
40+
# teens_digit = int(x)
41+
# ones_digit = int(x) % 10
42+
# y = int(x)
43+
44+
# if y>= 20:
45+
# converted_tens_digit = str(tens_digit)
46+
# converted_tens_digit_2 = tens[converted_tens_digit]
47+
# converted_ones_digit = str(ones_digit)
48+
# converted_ones_digit_2 = ones[converted_ones_digit]
49+
# print(f"\n{converted_tens_digit_2}-{converted_ones_digit_2}")
50+
51+
# elif y<10:
52+
# converted_ones_digit = str(ones_digit)
53+
# converted_ones_digit_2 = ones[converted_ones_digit]
54+
# print(f"\n{converted_ones_digit_2}")
55+
56+
# elif y in range (11, 19):
57+
# converted_teens_digit = str(teens_digit)
58+
# converted_teens_digit_2 = teens[converted_teens_digit]
59+
# print(f"\n{converted_teens_digit_2}")
60+
61+
#VERSION 2
62+
63+
ones = {
64+
"1":"One",
65+
"2":"Two",
66+
"3":"Three",
67+
"4":"Four",
68+
"5":"Five",
69+
"6":"Six",
70+
"7":"Seven",
71+
"8":"Eight",
72+
"9":"Nine",
73+
"0":"Zero"
74+
}
75+
teens = {
76+
"10":"Ten",
77+
"11":"Eleven",
78+
"12":"Twelve",
79+
"13":"Thirteen",
80+
"14":"Fourteen",
81+
"15":"Fifteen",
82+
"16":"Sixteen",
83+
"17":"Seventeen",
84+
"18":"Eighteen",
85+
"19":"Nineteen"
86+
}
87+
tens = {
88+
"2":"Twenty",
89+
"3":"Thirty",
90+
"4":"Fourty",
91+
"5":"Fifty",
92+
"6":"Sixty",
93+
"7":"Seventy",
94+
"8":"Eighty",
95+
"9":"Ninety"
96+
}
97+
hundreds = {
98+
"1":"One",
99+
"2":"Two",
100+
"3":"Three",
101+
"4":"Four",
102+
"5":"Five",
103+
"6":"Six",
104+
"7":"Seven",
105+
"8":"Eight",
106+
"9":"Nine"
107+
}
108+
109+
x = input("\nInput a number from 0-999: ")
9110
y = int(x)
111+
z = str(y)
112+
last2_digit = int(x) % 100
113+
hundreds_digit = int(x) // 100
114+
str_last2_digit = str(last2_digit)
115+
# tens_digit = str_last2_digit[0]
116+
# ones_digit = str_last2_digit[1]
117+
# converted_tens_digit = tens[tens_digit]
118+
# converted_ones_digit = ones[ones_digit]
119+
# converted_hundreds_digit = str(hundreds_digit)
120+
# converted_hundreds_digit_2 = hundreds[converted_hundreds_digit]
121+
122+
if y < 10:
123+
ones_digit = int(x) % 10
124+
converted_ones_digit = ones[str(ones_digit)]
125+
print(f"\n{converted_ones_digit}")
10126

11-
if y>= 20:
127+
elif y in range (10,19):
128+
teens_digit = int(x)
129+
converted_teens_digit = str(teens_digit)
130+
converted_teens_digit_2 = teens[converted_teens_digit]
131+
print(f"\n{converted_teens_digit_2}")
132+
133+
134+
elif 100 > y >= 21:
135+
tens_digit = int(x) // 10
136+
ones_digit = int(x) % 10
12137
converted_tens_digit = str(tens_digit)
13138
converted_tens_digit_2 = tens[converted_tens_digit]
14139
converted_ones_digit = str(ones_digit)
15140
converted_ones_digit_2 = ones[converted_ones_digit]
16141
print(f"\n{converted_tens_digit_2}-{converted_ones_digit_2}")
17142

18-
elif y<10:
19-
converted_ones_digit = str(ones_digit)
20-
converted_ones_digit_2 = ones[converted_ones_digit]
21-
print(f"\n{converted_ones_digit_2}")
22-
23-
elif y in range (11, 19):
24-
converted_teens_digit = str(teens_digit)
143+
elif z[1] == "1":
144+
last2_digit = int(x) % 100
145+
converted_teens_digit = str(last2_digit)
25146
converted_teens_digit_2 = teens[converted_teens_digit]
26-
print(f"\n{converted_teens_digit_2}")
147+
converted_hundreds_digit = str(hundreds_digit)
148+
converted_hundreds_digit_2 = hundreds[converted_hundreds_digit]
149+
print(f"\n{converted_hundreds_digit_2} Hundred {converted_teens_digit_2}")
150+
151+
elif y > 100:
152+
last2_digit = int(x) % 100
153+
hundreds_digit = int(x) // 100
154+
str_last2_digit = str(last2_digit)
155+
tens_digit = str_last2_digit[0]
156+
ones_digit = str_last2_digit[1]
157+
converted_tens_digit = tens[tens_digit]
158+
converted_ones_digit = ones[ones_digit]
159+
converted_hundreds_digit = str(hundreds_digit)
160+
converted_hundreds_digit_2 = hundreds[converted_hundreds_digit]
161+
print(f"\n{converted_hundreds_digit_2} Hundred {converted_tens_digit}-{converted_ones_digit}")

0 commit comments

Comments
 (0)