Professional Documents
Culture Documents
=====================
title()
~~~~~~~~~
Syntax:
----------
str.title()
eg:
capitalize()
-------------------
syntax:
~~~~~~~~~~
str.capitalize()
eg:
swapcase()
==============
Syntax:
~~~~~~~~~~~~
str.swapcase()
eg:
>>> str="abcdEFGHijklMNOPqrstUVWXyz"
>>> x=str.swapcase()
>>> print(x)
ABCDefghIJKLmnopQRSTuvwxYZ
>>>
Checking Type of string(s) Functions
========================================
isalnum()
~~~~~~~~~~
It is used to return or display True when the given string contains the
alphabets and numbers otherwise False will return
Syntax:
~~~~~~~~~
str.isalnum()
eg:
>>> str="python3"
>>> x=str.isalnum()
>>> print(x)
True
>>>
>>>
>>> str="python 3"
>>> x=str.isalnum()
>>> print(x)
False
>>>
isalpha()
~~~~~~~~~~~~~~
Syntax:
-------------
str.isaplha()
eg:
>>> str="PythonProgramming"
>>> x=str.isalpha()
>>> print(x)
True
>>>
>>>
>>>
>>> str="Python 3"
>>> x=str.isalpha()
>>> print(x)
False
>>>
>>>
isdigit()
~~~~~~~~~~~~~~~~
It is used to check the given string contains the digits only or not
Syntax:
-----------
str.isdigit()
eg:
>>> str="12345"
>>> x=str.isdigit()
>>> print(x)
True
>>>
>>>
>>> str="1234abcd"
>>> x=str.isdigit()
>>> print(x)
False
>>>
islower()
===========
It is used to return or display True if the given string contains only the
lower case characters
Syntax:
--------------
str.islower()
eg:
>>> str="hello"
>>> x=str.islower()
>>> print(x)
True
>>>
>>>
>>> str="Hello"
>>> x=str.islower()
>>> print(x)
False
isnumeric()
===============
It is used to return or display True all the characters in the given string
is numeric, otherwise False
str.isnumeric()
eg:
>>> str="12345"
>>> x=str.isnumeric()
>>> print(x)
True
>>>
>>>
>>> str="12345abcd"
>>> x=str.isnumeric()
>>> print(x)
False
>>>
isspace()
==============
Syntax:
~~~~~~~~~~~
str.isspace()
eg:
istitle()
--------------
It is used to return or display True, if the given string contains the title
case otherwise it will return False
Syntax:
~~~~~~~~~~
str.istitle()
eg:
>>> str="Welcome To The Programming World"
>>> x=str.istitle()
>>> print(x)
True
>>>
>>>
>>> str="welcome to The Programming World"
>>> x=str.istitle()
>>> print(x)
False
>>>
>>>
isupper()
===============
It is used to display or return True, if the given contains upper case only
otherwise it will return or display False
Syntax:
~~~~~~~~~~~~~~
str.isupper()
eg:
>>> str="HELLO"
>>> x=str.isupper()
>>> print(x)
True
>>>
>>> x=str.isupper()
>>> print(x)
False
>>>
center()
============
Syntax:
~~~~~~~~~~
str.center(width[,fillchar])
eg:
ljust()
~~~~~~~~~~~~~~
Syntax:
---------
str.ljust(width[,fillchar])
eg:
>>> str="hello"
>>> x=str.ljust(15,"@")
>>> print(x)
hello@@@@@@@@@@
>>>
rjust()
~~~~~~~~~~~~~~
Syntax:
---------
str.rjust(width[,fillchar])
eg:
>>> str="hello"
>>> x=str.rjust(15,"@")
>>> print(x)
@@@@@@@@@@hello
>>>
zfill()
------------
It is used to display or return the given string & Left padded with zero(s)
Syntax:
~~~~~~~~~~~~
str.zfill(width)
eg:
>>> str="hello"
>>> x=str.zfill(15)
>>> print(x)
0000000000hello
>>>
>>>
>>>
>>> str="hello"
>>> x=str.zfill(5)
>>> print(x)
hello
>>>
>>>
>>>
>>> str="12345"
>>> x=str.zfill(10)
>>> print(x)
0000012345
>>>