-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoperators.py
98 lines (69 loc) · 1.27 KB
/
operators.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# -*- coding: utf-8 -*-
"""operators.ipynb
Automatically generated by Colaboratory.
Original file is located at
https://colab.research.google.com/drive/1MUVKqNonqI_VLXhf9Y-snCdGbBmHoAgQ
"""
m = 15
n = 4
# Output: m + n = 19
print('m + n =',m+n)
# Output: m - n = 11
print('m - n =',m-n)
# Output: m * n = 60
print('m * n =',m*n)
# Output: m / n = 3.75
print('m / n =',m/n)
a = 10
b = 12
# Output: a > b is False
print('a > b is',a>b)
# Output: a < b is True
print('a < b is',a<b)
# Output: a == b is False
print('a == b is',a==b)
# Output: a != b is True
print('a != b is',a!=b)
# Output: a >= b is False
print('a >= b is',a>=b)
# Output: a <= b is True
print('a <= b is',a<=b)
m = True
n = False
print('m and n is',m and n)
print('x or y is',x or y)
print('not x is',not x)
x=10
y= 4
x & y = 0 (0000 0000)
x ^ y = 14 (0000 1110)
x << 2 = 40 (0010 1000)
x >> 2 = 2 (0000 0010)
a=2
a += 5
a %= 5
a **= 5
a //= 5
print(a)
x1 = 10
y1 = 10
x2 = 'Welcome'
y2 = 'Welcome'
x3 = [10,20,30]
y3 = [10,20,30]
# Output: False
print(x1 is not y1)
# Output: True
print(x2 is y2)
# Output: False
print(x3 is y3)
x = 'Hello world'
y = {1:'a',2:'b'}
# Output: True
print('H' in x)
# Output: True
print('hello' not in x)
# Output: True
print(1 in y)
# Output: False
print('a' in y)