-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpython operators.py
More file actions
88 lines (70 loc) · 1.03 KB
/
python operators.py
File metadata and controls
88 lines (70 loc) · 1.03 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
print(10+5)
print(5-10)
print(5/2)
print(5*2)
print(5%2)
print(5**2)
print(5//2)
x = 5
print(x)
x +=3
print(x)
x = 5
x -=3
print(x)
x = 5
x *=3
print(x)
x = 5
x /=3
print(x)
print('miracle')
x= 5
x %=3
print(x)
x= 5
x **=3
print(x)
#functions as binary numbers
x=15
x &=3
print(x)
x = 5
x |=3
print(x)
print('confident')
x= 5
x ^= 3
print(x)
x = 5
x >>=3
print(x)
x = 5
x <<=3
print(x)
#not equal to
x = 5
y = 3
print(x != y)
# returns True because five is greater, or equal, to 3
x=5
y=3
print(x>=y)
x = 5
print(x > 3 and x < 10)
x = 5
print(x > 3 or x < 4)
x = 5
print(not(x > 3 and x < 10))
# returns False because not is used to reverse the result
x = ["apple", "banana"]
y = ["apple", "banana"]
z = x
print(x is z)
# returns True because z is the same object as x
print(x is y)
# returns False because x is not the same object as y, even if they have the same content
print(x == y)
# to demonstrate the difference betweeen "is" and "==": this comparison returns True because x is equal to y
print('banana' in x)
print('banana' not in x)