I. data types, literals¶

basic data types¶

  • Boolean (and, or, not)
  • Numbers (+,-,*,/,//,%,str)
  • Strings (slice, split, strip, int)
In [ ]:
True
Out[ ]:
True
In [ ]:
False
Out[ ]:
False

3 types of input: command line, keyboard, file

In [ ]:
True and False
Out[ ]:
False
In [ ]:
not True
Out[ ]:
False
In [ ]:
(True and False) or True
Out[ ]:
True
In [ ]:
45 + 72
Out[ ]:
117
In [ ]:
45/2
Out[ ]:
22.5
In [ ]:
45//2
Out[ ]:
22
In [ ]:
45%2
Out[ ]:
1
In [ ]:
str(45)
Out[ ]:
'45'
In [ ]:
"Raj"
Out[ ]:
'Raj'
In [ ]:
"Raj" + "shekhar"
Out[ ]:
'Rajshekhar'
In [ ]:
"Hello"[0]
Out[ ]:
'H'
In [ ]:
"Hello"[0:2]
Out[ ]:
'He'
In [ ]:
"Hello"[2:5]
Out[ ]:
'llo'
In [ ]:
"Hello"[2:]
Out[ ]:
'llo'
In [ ]:
len("Hello")
Out[ ]:
5

Variables and Assignment Statement, print statement¶

In [ ]:
x = 25
In [ ]:
print(x)
25
In [ ]:
print(y)
50
In [ ]:
y = 50
In [ ]:
print(y)
50
In [ ]:
z = x + y
print(z)
75

Collection Data Structure: list¶

In [ ]:
names = ["Raj","John","Jim"]
In [ ]:
names[0:2]
Out[ ]:
['Raj', 'John']
In [ ]:
names[0]
Out[ ]:
'Raj'
In [ ]:
len(names)
Out[ ]:
3