2 Basic of Python - Functions
2 Basic of Python - Functions
Functions
In [1]:
a = "welcome"
In [2]:
a.capitalize()
Out[2]: 'Welcome'
In [3]:
# Dot and tab will provide you the list of functions. We can use them directly
In [3]:
b = "money"
In [4]:
b
Out[4]: 'money'
In [5]:
# It will comvert first letter of word into Captial
b = b.capitalize()
In [6]:
b
Out[6]: 'Money'
In [6]:
# it will convert word in lower case letter
b = b.lower()
In [7]:
b
Out[7]: 'money'
In [8]:
# It will convert all letters in Captial
b = b.upper()
In [9]:
b
Out[9]: 'MONEY'
In [11]:
# to Find the index of letter in word
b.find("N")
Out[11]: 2
In [10]:
# To check Upper case data is upper case or not
b.isupper()
Out[10]: True
In [11]:
# to Check Data is lower case or not
b.islower()
Out[11]: False
In [14]:
f="Hello World"
In [15]:
# number of times repeating
f.count("l")
Out[15]: 3
In [16]:
# replace the existing letters with new letters
In [17]:
f
In [1]:
c = " welcome to Data science"
In [2]:
c.split()
In [13]:
a = " Hello world "
In [14]:
# Strip method remove the white space from the string
a.strip()
In [21]:
age = 36
In [22]:
test
In [8]:
test.format(age)
In [ ]: