Q. Write a program to convert a number entered by the user into its corresponding number in words.

For example, if the input is 876 then the output should be 'Eight Seven Six'.

(Hint. use dictionary for keys 0-9 and their values as equivalent words.)


Answer :-

num = input ("Enter a number :- ")
dic = { "0" : "Zero" , "1":"One" , "2" : "Two" , "3" : "Three" , "4" : "Four" , "5" : "Five" , "6" : "Six" , "7" : "Seven" , "8" : "Eight" , "9" : "Nine"}

for i in num :
      print( dic[ i ], end = " ")

Output :-

Enter a number :- 876
Eight Seven Six 

>>> 

Enter a number :- 15
One Five 

>>> 

Enter a number :- 46536
Four Six Five Three Six 

>>> 


28 Comments

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

  1. Can u pls type the output of this ques...?

    ReplyDelete
    Replies
    1. Copy the code run it in your IDLE python : )

      Delete
  2. Will I get 5marks by writing this much only because in a sample paper this Q. Was there in the 5 marks section.

    ReplyDelete
  3. Mam it doesn't work on the application

    ReplyDelete
  4. Replies
    1. It is working please run in your idle python.

      Delete
  5. thx to who ever created this content:)

    ReplyDelete
  6. I want to work with uh.

    ReplyDelete
  7. How to write this program using function?

    ReplyDelete
  8. its good,thanks

    ReplyDelete
  9. can u pls write like using tens, for eg 765 its seven sixty five ,pretty pls give it 😊

    ReplyDelete
  10. will i get full marks of only this much answer .the ques was of 6 marks

    ReplyDelete
  11. aag laga diya

    ReplyDelete
  12. Broooo its not dic (k) its dict for dictionary

    ReplyDelete
  13. your name is on fbi list, i am an fbi agent, out of sympathy to you i want you to be careful. helicopters will land on your house, so go to another country and hide your identity. peace

    ReplyDelete

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post