27th Sep 2020, 8:49 AM
Ankit Chouhan
Ankit Chouhan - avatar
6 Answers
0
I Found an error if you enter 300 or 400 it will become fourhandred and or threehundreds and You have to use if to remove the and
27th Sep 2020, 9:08 AM
Ruba Kh
Ruba Kh - avatar
+ 1
one more problem is, if we enter 113 than output is "one hundred and ten three"!!! so please help!!!!
27th Sep 2020, 10:58 AM
Ankit Chouhan
Ankit Chouhan - avatar
0
No error found?
27th Sep 2020, 9:00 AM
v@msi😉
v@msi😉 - avatar
0
Some thing like this #convert given numerical to word. minimum=0 maximum=999 words_upto_19=['','ONE','TWO','THREE','FOUR','FIVE','SIX', 'SEVEN','EIGHT','NINE','TEN','ELEVEN','TWELVE','THIRTEEN','FOURTEEN','FIFTEEN','SIXTEEN','SEVENTEEN','EIGHTEEN','NINETEEN'] words_for_tens=['','Ten','TWENTY','THIRTY','FOURTY','FIFTY','SIXTY','SEVENTY','EIGHTY','NINETY'] n=int(input('Enter a number from 0 to 999:')) output='' if n==0: output='ZERO' elif n<=19: output=words_upto_19[n] elif n<=99: output=words_for_tens[n//10]+" "+words_upto_19[n%10] elif n<=999: output = words_upto_19[n//100] +' HUNDRED ' if words_for_tens[(n//10)%10] != '' or words_upto_19[n%10] != '': output+='AND '+words_for_tens[(n//10)%10]+" "+words_upto_19[n%10] else: output='Please enter a value from 0 to 999 only' print(output)
27th Sep 2020, 9:13 AM
Ruba Kh
Ruba Kh - avatar
0
Try this #convert given numerical to word. minimum=0 maximum=999 words_upto_19=['','ONE','TWO','THREE','FOUR','FIVE','SIX', 'SEVEN','EIGHT','NINE','TEN','ELEVEN','TWELVE','THIRTEEN','FOURTEEN','FIFTEEN','SIXTEEN','SEVENTEEN','EIGHTEEN','NINETEEN'] words_for_tens=['','TEN','TWENTY','THIRTY','FOURTY','FIFTY','SIXTY','SEVENTY','EIGHTY','NINETY'] n=int(input('Enter a number from 0 to 999:')) output='' if n==0: output='ZERO' elif n<=19: output=words_upto_19[n] elif n<=99: output=words_for_tens[n//10]+" "+words_upto_19[n%10] elif n<=999: output = words_upto_19[n//100] +' HUNDRED ' if words_for_tens[(n//10)%10] == 'TEN' and words_upto_19[n%10] != '': output+='AND '+words_upto_19[n%100] elif words_for_tens[(n//10)%10] != '' or words_upto_19[n%10] != '': output+='AND '+words_for_tens[(n//10)%10]+" "+words_upto_19[n%10] else: output='Please enter a value from 0 to 999 only' print(output)
27th Sep 2020, 12:31 PM
Ruba Kh
Ruba Kh - avatar
0
Plz run this program on your pc version, sometime the program is not running properly on this app.
28th Sep 2020, 2:34 AM
Ashutosh Pattnaik
Ashutosh Pattnaik - avatar