Program to print the given digit in words | Function to return the word of the corresponding digit ; For digit 0 ; For digit 1 ; For digit 2 ; For digit 3 ; For digit 4 ; For digit 5 ; For digit 6 ; For digit 7 ; For digit 8 ; For digit 9 ; Function to iterate through every digit in the given number ; Finding each digit of the number ; Print the digit in words ; Driver code
def printValue ( digit ) : NEW_LINE INDENT if digit == '0' : NEW_LINE INDENT print ( " Zero ▁ " , end = " ▁ " ) NEW_LINE DEDENT elif digit == '1' : NEW_LINE INDENT print ( " One ▁ " , end = " ▁ " ) NEW_LINE DEDENT elif digit == '2' : NEW_LINE INDENT print ( " Two ▁ " , end = " ▁ " ) NEW_LINE DEDENT elif digit == '3' : NEW_LINE INDENT print ( " Three " , end = " ▁ " ) NEW_LINE DEDENT elif digit == '4' : NEW_LINE INDENT print ( " Four ▁ " , end = " ▁ " ) NEW_LINE DEDENT elif digit == '5' : NEW_LINE INDENT print ( " Five ▁ " , end = " ▁ " ) NEW_LINE DEDENT elif digit == '6' : NEW_LINE INDENT print ( " Six ▁ " , end = " ▁ " ) NEW_LINE DEDENT elif digit == '7' : NEW_LINE INDENT print ( " Seven " , end = " ▁ " ) NEW_LINE DEDENT elif digit == '8' : NEW_LINE INDENT print ( " Eight " , end = " ▁ " ) NEW_LINE DEDENT elif digit == '9' : NEW_LINE INDENT print ( " Nine ▁ " , end = " ▁ " ) NEW_LINE DEDENT DEDENT def printWord ( N ) : NEW_LINE INDENT i = 0 NEW_LINE length = len ( N ) NEW_LINE while i < length : NEW_LINE INDENT printValue ( N [ i ] ) NEW_LINE i += 1 NEW_LINE DEDENT DEDENT N = "123" NEW_LINE printWord ( N ) NEW_LINE