1+1
2
2*2
4
2/2
1.0
a = 2
a
2
print(a)
2
print("Hi this is python")
Hi this is python
print("value of a is {}".format(a))
value of a is 2
b = 3
b=4
print("a is {one} and b is {two}".format(one=a,two=b))
a is 2 and b is 4
a = [1,2,3]
print(a)
[1, 2, 3]
b = (1,2,3)
print(b)
(1, 2, 3)
c = {1,2,3}
print(c)
{1, 2, 3}
a[0] = 5
a
[5, 2, 3]
b
(1, 2, 3)
b[0] = 5
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-32-e95e2eb675dd> in <module>
----> 1 b[0] = 5
TypeError: 'tuple' object does not support item assignment
{1,2,3}
{1, 2, 3}
{1,2,3,1,2,1,3,2,1}
{1, 2, 3}
a == a
True
a != 1
True
x = 1
y = 2
x > 1
False
x < 1
False
a
[5, 2, 3]
x = 2
z = "1"
x == z
False
if(x == 1):
y = x*2
print("equals")
equals
x=3
if x == 1:
y = x*2
print("equals")
elif x==2:
print("2")
else:
print("3")
3
a
[5, 2, 3]
a.append(6)
a
[5, 2, 3, 6]
a[1]
2
a[1:3]
[2, 3]
a[1:]
[2, 3, 6]
a[2:]
[3, 6]
a[:2]
[5, 2]
a
[5, 2, 3, 6]
b = [4,3,2,1]
a
[5, 2, 3, 6]
x
3
x ** 2
9
for i in a:
if(i==3):
print("equals 3")
else:
print("not 3")
not 3
not 3
equals 3
not 3
d = 1
while d < 5:
print(d)
d+=1
1
2
3
4
t = (1,2,3)
t[0:2]
(1, 2)
h = {"a": 1, "b": 2, "c" : 3, 3: 78 }
h
{'a': 1, 'b': 2, 'c': 3}
print(h[3])
78
[1,2,3]
[1, 2, 3]
p = [ [1,2], [2,3], [7,8] ]
p[0]
[1, 2]
p[0][1]
2
int("3")
3
import jovian
jovian.commit()
[jovian] Saving notebook..