Python Strings: Mahendra K. Verma

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

Python Strings

Mahendra K. Verma

Character
‘a’, ‘b’,’1’,’अ ‘, ‘$’

In [1]: x='2'

In [2]: ord(x) # returns ascii representation of x


Out[2]: 50

In [36]: chr(50)
Out[36]: '2'

Strings
In [14]: x = "This is a string.

In [15]:
Out[15]: 'This is a string.

In [17]: x+" Hi, string?


Out[17]: 'This is a string. Hi, string?

In [71]: 5*'S'
Out[71]: ‘SSSSS'

In [121]: y= "abs \ncde"

In [123]: print(y)
abs
cde

In [126]: print('\u0905')

In [132]: print('\x55')
U

"

Input/Output
In [18]: x=

In [19]: print (“x=", x


x= 5

In [20]: x = input("Enter the value of x ="


Enter the value of x =1

In [21]:
Out[21]: ’10'
x

Thank you!

You might also like