-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoperators.py
More file actions
96 lines (69 loc) · 1.1 KB
/
operators.py
File metadata and controls
96 lines (69 loc) · 1.1 KB
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
"""Arithmetic Operators"""
# print(5/2)
# print(-5/2)
# print(-5/-2)
# print(-5.0/2)
# print(-5/2.0)
# a = 17
# b = 9
# c = a//b
# print(c)
# a = 2
# b = 5
# c = 9
"""Comparison Operators"""
# print(a<b)
# print(a>b)
# print(a==c)
# print(a!=b)
# print(a>=b)
# print(b<16<b**3!=125)
"""Assignment Operators"""
# x = 3
# y = 1
# x+=5
# print(x)
# x-=10
# print(x)
# x*=-10
# print(x)
# y+=y
# print(y)
# x=21
# x/=y
# print(x)
# p = 21
# q = 2
# p%=q
# print(p)
# p+=1
# p**=q
# print(p)
# logical operatours
# x = 10
# y = 10
# print(x == 18 or not x<y or x==y)
# identity
# print(x is y,x==y)
# print(x is not y,x!=y)
# member ship
# x = "Hello "
# print('H' in x)
x = {1:1,2:3,3:7}
print(3 in x)
# x = 11
# y =567
# print(bin(x))
# print(bin(y))
# print(bin(x^y))
# Python program to illustrate the use
# of 'is' and '==' operators
a = [1, 2, 3]
b = [1, 2, 3]
x = {1:'hello',2:3.5,3:7.9}
y = {1:'hello',2:3.5,3:7.9}
# using 'is' and '==' operators
print(a is b)
print(a == b)
print(x is y)
print(x == y)