Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

# Function that \"says\" the digits of a number an integar. # ex , 234 >> two th

ID: 3711570 • Letter: #

Question

# Function that "says" the digits of a number an integar. # ex , 234 >> two three four # 2345 # 2345 % 10 = 5 # 2345 // 10 = 234 # 234 % 10 = 4 # 234 // 10 = 23 # 23 % 10 = 3 # 23 // 10 = 2 # 2 % 10 = 2 # 2 // 10 = 0 # convert a number to word? # name = ["Zero, "one", "two", "three", .... ] #print the name & digits of n Basically, it translate the digits to its name. for example, if the input 458 >> the output should be >> "Four", "Five", "Eight"

Sorry forget to mention. Python 3.x

Explanation / Answer

def digit(x):#function to map the value of t to list d, actually t will be used as the index of d
while (x>0):
t=int(x%10)
x=int(x//10)
mylist.append(d[t])#appending d to the newlist
print(mylist)

mylist=[]   
d=["zero","one","two","three","four","five","six","seven","eight","nine"]#as the indexing of the list is from 0 so
num=input('enter a no.') #if i access d[0],it will be zero d[1]=one,d[2]=two,....
Number=int(num)

Reverse=0#reversing the entered no here because in the func digit it accesses from the last digit ,so to print it right i reversed the num
while(Number > 0):
Reminder =int( Number %10)#last digit of the number
Reverse = (Reverse *10) + Reminder#formula for reversing a number
Number = int(Number //10)#reducing the no by one digit by removing the last digit
Reverse=int(Reverse)
digit(Reverse)#function call