Computer Science

Write a short program to input a digit and print it in words.

Python

Python Control Flow

60 Likes

Answer

d = int(input("Enter a digit(0-9): "))

if d == 0 :
    print("Zero")
elif d == 1 :
    print("One")
elif d == 2 :
    print("Two")
elif d == 3 :
    print("Three")
elif d == 4 :
    print("Four")
elif d == 5 :
    print("Five")
elif d == 6 :
    print("Six")
elif d == 7 :
    print("Seven")
elif d == 8 :
    print("Eight")
elif d == 9 :
    print("Nine")
else :
    print("Invalid Digit")

Output

Enter a digit(0-9): 6
Six

Answered By

24 Likes


Related Questions