Jovian
⭐️
Sign In
In [1]:
1+1
Out[1]:
2
In [1]:
2*2
Out[1]:
4
In [2]:
2/2
Out[2]:
1.0
In [3]:
a = 2
In [4]:
a
Out[4]:
2
In [5]:
print(a)
2
In [6]:
print("Hi this is python")
Hi this is python
In [7]:
print("value of a is {}".format(a))
value of a is 2
In [11]:
b = 3
In [13]:
b=4
print("a is {one} and b is {two}".format(one=a,two=b))
a is 2 and b is 4
In [25]:
a = [1,2,3]
print(a)
[1, 2, 3]
In [26]:
b = (1,2,3)
print(b)
(1, 2, 3)
In [27]:
c = {1,2,3}
print(c)
{1, 2, 3}
In [28]:
a[0] = 5
In [29]:
a
Out[29]:
[5, 2, 3]
In [30]:
b
Out[30]:
(1, 2, 3)
In [32]:
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
In [33]:
{1,2,3}
Out[33]:
{1, 2, 3}
In [34]:
{1,2,3,1,2,1,3,2,1}
Out[34]:
{1, 2, 3}
In [36]:
a == a
Out[36]:
True
In [37]:
a != 1
Out[37]:
True
In [39]:
x = 1
y = 2
In [40]:
x > 1
Out[40]:
False
In [41]:
x < 1
Out[41]:
False
In [42]:
a
Out[42]:
[5, 2, 3]
In [53]:
x = 2
In [44]:
z = "1"
In [45]:
x == z
Out[45]:
False
In [51]:
if(x == 1):
    y = x*2
    print("equals")
equals
In [57]:
x=3
if x == 1:
    y = x*2
    print("equals")
elif x==2:
    print("2")
else:
    print("3")
3
In [58]:
a
Out[58]:
[5, 2, 3]
In [59]:
a.append(6)
a
Out[59]:
[5, 2, 3, 6]
In [60]:
a[1]
Out[60]:
2
In [62]:
a[1:3]
Out[62]:
[2, 3]
In [63]:
a[1:]
Out[63]:
[2, 3, 6]
In [64]:
a[2:]
Out[64]:
[3, 6]
In [65]:
a[:2]
Out[65]:
[5, 2]
In [68]:
a
Out[68]:
[5, 2, 3, 6]
In [76]:
b = [4,3,2,1]
In [81]:
a
Out[81]:
[5, 2, 3, 6]
In [79]:
x
Out[79]:
3
In [80]:
x ** 2
Out[80]:
9
In [87]:
for i in a:
    if(i==3):
        print("equals 3")
    else:
        print("not 3")
not 3 not 3 equals 3 not 3
In [112]:
d = 1
while d < 5:
    print(d)
    d+=1
1 2 3 4
In [113]:
t = (1,2,3)
In [115]:
t[0:2]
Out[115]:
(1, 2)
In [138]:
h = {"a": 1, "b": 2, "c" : 3, 3: 78 }
In [125]:
h
Out[125]:
{'a': 1, 'b': 2, 'c': 3}
In [139]:
print(h[3])
78
In [140]:
[1,2,3]
Out[140]:
[1, 2, 3]
In [146]:
p = [ [1,2], [2,3], [7,8] ]
In [147]:
p[0]
Out[147]:
[1, 2]
In [148]:
p[0][1]
Out[148]:
2
In [150]:
int("3")
Out[150]:
3
In [151]:
import jovian
In [ ]:
jovian.commit()
[jovian] Saving notebook..
In [ ]: