Skip to content

Commit 69ce422

Browse files
committed
Lab3 Update
1 parent c401102 commit 69ce422

File tree

1 file changed

+49
-12
lines changed

1 file changed

+49
-12
lines changed

code/daniel/03_NumberToPhrase/NumberToPhrase.py

Lines changed: 49 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,11 @@
1818
# Convert a time given in hours and minutes to a phrase.
1919
#===================================================================================
2020

21+
from ast import NotIn
2122
import numbers
2223

24+
from cupshelpers import activateNewPrinter
25+
2326

2427
onesNumberList = {
2528
0: "zero",
@@ -44,33 +47,67 @@
4447
17: "seventeen",
4548
18: "eighteen",
4649
19: "ninteen",
47-
2: "twenty",
48-
3: "thirty",
49-
4: "fory",
50-
5: "fifty",
51-
6: "sixty",
52-
7: "seventy",
53-
8: "eighty",
54-
9: "ninty",
50+
20: "twenty",
51+
30: "thirty",
52+
40: "fory",
53+
50: "fifty",
54+
60: "sixty",
55+
70: "seventy",
56+
80: "eighty",
57+
90: "ninty",
5558
}
5659

5760
pickANumber = input("Pick a number between 0 and 99: ")
5861
intNum = int(pickANumber)
59-
wordNum = ""
62+
# wordNum = ""
6063
tens_digit = intNum//10
6164
ones_digit = intNum%10
6265
actual_digit = (f"{tens_digit}{ones_digit}")
6366

6467
# print(f"{tens_digit}{ones_digit}")
6568
# print(actual_digit)
6669

70+
#====================================
6771
while intNum > 99 or intNum < 0:
6872
print(f"Number is out of range")
6973
break
7074

71-
while intNum != "":
72-
if tens_digit == 0:
73-
wordNum = ones_digit[intNum()]
75+
# print(onesNumberList.get(int(6)))
76+
while True:
77+
if intNum in onesNumberList:
78+
print(str(onesNumberList[intNum]))
79+
break
80+
elif intNum in tensNumberList:
81+
print(str(tensNumberList[intNum]))
82+
break
83+
elif intNum not in onesNumberList and intNum not in tensNumberList:
84+
print(str(tensNumberList[intNum//10]) + str(onesNumberList[intNum%10]))
85+
break
86+
87+
88+
89+
90+
91+
92+
93+
94+
95+
96+
97+
98+
99+
100+
101+
#====================================
102+
103+
104+
# while intNum > 99 or intNum < 0:
105+
# print(f"Number is out of range")
106+
# break
107+
108+
# while intNum != "":
109+
# if tens_digit == 0:
110+
# wordNum = ones_digit[intNum]
74111

75112

76113

0 commit comments

Comments
 (0)