-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path5. operators.py
More file actions
36 lines (28 loc) · 829 Bytes
/
5. operators.py
File metadata and controls
36 lines (28 loc) · 829 Bytes
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
#operators perform specific operation. eg. addition, multiplication, division.
#operand are the variables.
#1 Arithmetic Operators: +, -, *, /, %, **, //
#**-> power, //-> floor Division--remove the decimal values. 2.6 --> 2
a = 3
b = 4
c = a**b #change acording to you.
print(c) #result should 81.
#2 Relational Operator/Comparison Operator, Result: true/false
#operators are: >,<,==,!=,<>,<=,>= .
a = 3
b = 3
c = a==b #change acording to you.
print(c) #result should true.
#3 Assing Operators : =,+=,-=,/=,*=,%=
a = 10
b = 20
a += b
print(a) #output: 30
#4 Logical Operators: and, or, not
#AND - it return true if all the statements are true.
#OR - it return true if any statemrnt is true.
#NOT - it reverse the return true to false and false to true.
a = 10
b = 20
c = 30
d = ((a>b)and(a>c))
print(d) #output -- false