Professional Documents
Culture Documents
DS Program File 5
DS Program File 5
import random
print(random.randint(1, 10))
print(random.randrange(1, 20))
print(random.randrange(0,5))
print(random.randrange(-20, -10))
5
14
3
-20
randnums= numpy.random.randint(1,100,5)
print(randnums)
[ 1 92 41 44 67]
H
e
l
l
o
,
W
o
r
l
d
!
H
e
l
l
o
,
W
o
r
l
d
!
True
True
localhost:8888/notebooks/DS_Program_File_5.ipynb# 1/4
3/7/2021 DS_Program_File_5 - Jupyter Notebook
True
False
False
In [40]: a = 200
b = 20
if b > a:
print("b is greater than a")
elif b < a:
print("b is not greater than a")
else:
print("b is equal to a")
x = "Hello"
y = 15
z=0
s=-10
b=" "
r="" # empty string
print(bool(x))
print(bool(y))
print(bool(z))
print(bool(s))
print(bool(b))
print(bool(r))
True
True
False
True
True
False
In [48]: bool("abc")
Out[48]: True
In [49]: bool(123)
Out[49]: True
Out[50]: True
In [51]: bool(False)
Out[51]: False
In [52]: bool(None)
Out[52]: False
In [53]: bool(())
Out[53]: False
In [54]: bool([])
Out[54]: False
In [55]: bool({})
Out[55]: False
In [60]: x = 200
print(isinstance(x, int)) #chk if an object is integer or not
True
localhost:8888/notebooks/DS_Program_File_5.ipynb# 2/4
3/7/2021 DS_Program_File_5 - Jupyter Notebook
print(10 + 5)
15
In [62]: print(10 - 5)
In [63]: print(10 * 5)
50
In [72]: print(12 / 5)
2.4
1000
-3
In [83]: print(5 == 5)
True
In [84]: print(2 != 5)
True
True
In [86]: print(2<= 5)
True
True
True
Out[90]: False
localhost:8888/notebooks/DS_Program_File_5.ipynb# 3/4
3/7/2021 DS_Program_File_5 - Jupyter Notebook
a is really in x
e is really not in x
False
True
In [ ]:
localhost:8888/notebooks/DS_Program_File_5.ipynb# 4/4