Primitive Data Types in Python¶

Boolean¶

In [17]:
True
Out[17]:
True
In [18]:
False
Out[18]:
False
In [19]:
not True
Out[19]:
False
In [20]:
not False
Out[20]:
True
In [21]:
True and False
Out[21]:
False
In [22]:
True or False
Out[22]:
True

Number¶

In [23]:
23
Out[23]:
23
In [24]:
-22.5
Out[24]:
-22.5
In [25]:
20 + 30
Out[25]:
50
In [26]:
20 * 30
Out[26]:
600
In [27]:
27 / 2
Out[27]:
13.5
In [1]:
27 // 2
Out[1]:
13
In [16]:
27 % 2
Out[16]:
1

String¶

In [4]:
"Raj's phone is 1111"
Out[4]:
"Raj's phone is 1111"
In [5]:
'''
Hello
Hello
'''
Out[5]:
'\nHello\nHello\n'
In [12]:
'''
This is a
multi line comment
in python can contain digits 1 2 3 and symbols !@#$$%^&*() 
and "double quotes" and 'single quotes' 
'''
Out[12]:
'\nThis is a\nmulti line comment\nin python can contain digits 1 2 3 and symbols !@#$$%^&*() \nand "double quotes" and \'single quotes\' \n'

Variables¶

In [8]:
s = "Hello"
In [9]:
s[0]
Out[9]:
'H'
In [10]:
s[1]
Out[10]:
'e'
In [11]:
s + s
Out[11]:
'HelloHello'