top of page
learn_data_science.jpg

Data Scientist Program

 

Free Online Data Science Training for Complete Beginners.
 


No prior coding knowledge required!

Converting numbers into words

Updated: Sep 11, 2021

I started by defining a function which enable the user to enter input values

of number needed to be converted into words



#Defining a function


y=int(input("Number To Words Converter:-\n\nEnter Number: "))

x,tyu=str(y),print("\n")

import sys

if int(x)>10**100 or int(x)<0:sys.exit("Range Is From Zero To One Googol!")

def num1wrd(x,w={0:"",1:"One",2:"Two",3:"Three",4:"Four",5:"Five",6:"Six",7:"Seven",8:"Eight",9:"Nine"},f={2:"Twen",3:"Thir",4:"For",5:"Fif",6:"Six",7:"Seven",8:"Eigh",9:"Nine"},t={11:"Eleven",12:"Twelve",13:"Thirteen",14:"Fourteen",15:"Fifteen",16:"Sixteen",17:"Seventeen",18:"Eighteen",19:"Nineteen"}):

if len(x)==1:return(w[int(x)])

elif len(x)==2 and x[0]=="0" and x[1]=="0":return("")

elif len(x)==2 and x[0]=="0":return (w[int(x[1])])

elif len(x)==2:

if int(x) in range(11,20):return(t[int(x)])

elif int(x[1])==0:

if int(x)==10:return("Ten")

else:return(f[int(x[0])]+"ty")

else:return(f[int(x[0])]+"ty"+"-"+w[int(x[1])])

s=s1[:len(s1)-3]

print("》 "+s+".")


After running the function shown in the above image below is a pop up which enable the user to input any value.


After clicking enter below is the result of 475 in words.








 
 
 

2件のコメント


Data Insight
Data Insight
2021年9月11日

Input your code into code snippet and provide link to the GitHub repository.

いいね!
fredy chimire
fredy chimire
2021年9月12日
返信先

Well noted and actioned

いいね!

COURSES, PROGRAMS & CERTIFICATIONS

 

Advanced Business Analytics Specialization

Applied Data Science with Python (University of Michigan)

Data Analyst Professional Certificate (IBM)

Data Science Professional Certificate (IBM)

Data Science Specialization (John Hopkins University)

Data Science with Python Certification Training 

Data Scientist Career Path

Data Scientist Nano Degree Program

Data Scientist Program

Deep Learning Specialization

Machine Learning Course (Andrew Ng @ Stanford)

Machine Learning, Data Science and Deep Learning

Machine Learning Specialization (University of Washington)

Master Python for Data Science

Mathematics for Machine Learning (Imperial College London)

Programming with Python

Python for Everybody Specialization (University of Michigan)

Python Machine Learning Certification Training

Reinforcement Learning Specialization (University of Alberta)

Join our mailing list

Data Insight participates in affiliate programs and may sometimes get a commission through purchases made through our links without any additional cost to our visitors.

bottom of page