Python program to take a number between 0 to 9 and print the word representation for that number
Following program shows you how to take a number between 0 to 9 and print the word representation for that number.
In this program we get numbers between 0 to 9 from user and print word representation using if condition
num = int(input("Enter a number between 0 to 9:"))
if (num == 0):
print("Zero")
elif (num == 1):
print("One")
elif (num == 2):
print("Two")
elif (num == 3):
print("Three")
elif (num == 4):
print("Four")
elif (num == 5):
print("Five")
elif (num == 6):
print("Six")
elif (num == 7):
print("Sevan")
elif (num == 8):
print("Eight")
elif (num == 9):
print("Nine")
else:
print("We don't have word representation for that number")
Output:
Example1:
Enter a number between 0 to 9: 2
Two
Example2:
Enter a number between 0 to 9: 7
Seven
Example3:
Enter a number between 0 to 9: -6
We don't have word representation for that number