You are on page 1of 3

CLICK 11-A REVIEWER FOR FINALS

ARITHMETIC OPERATORS
- Nothing but operators that are used to perform arithmetic operations between
variables or two values.

`TYPES OF ARITHMETIC OPERATORS`

operator description example

Addition (+) Add two operands or unary plus. X+Y+2

Subtraction (-) Subtracts right hand operand from left hand X-Y-2
operand.

Multiplication (*) Multiplies values on either side of the operator. X*Y

Division (/) Divides left hand operand by right hand operand. X/Y

Modulus Modulus- divides left hand operand by right hand X % Y (reminder


Division (%) operand and returns remainder. of X/Y)

Exponentiation Perform exponential (power) calculation on X ** Y (X to the


(**) operation. power of Y)

Floor Division Division that results into whole number adjusted X // Y


(//) to the left in the number line.

ASSIGNMENT OPERATORS
- Are used to assign a value to a variables or any values that we have in Python.

TYPES OF ASSIGNMENT OPERATORS

Operator Description example

= Assigns value from the right C = A + B ( assign value of X = 500


side operand to the left side A+B into C ) print (x)
operand. Output: 500

+= Add AND - It adds right C += A ( is equivalent to C X=9


operand to the left operand =C+A) X += 5
and assign the result to the left print (x)
operand. Output: 14

-= Subtract AND- It subtract right C -= A ( is equivalent to C X = 60


operand from the left operand = C - A) X -= 35
and assign the result to the left print (x)
operand. Output: 25
*= Multiply AND- It multiplies the C *= (is equivalent to C = * X=5
right operand with the left A) X *= 3
operand and assign the result print (x)
to the left operand. Output: 15

/= Divide AND- It divides the left C /= A ( is equivalent to C X = 15


operand with the right operand = C / A) X /= 5
and assign the result to the left print (x)
operand. Output: 3.0

%= Modulus AND- It takes C %= A ( is equivalent to C X = 25


modulus using two operands = C % A) X %= 4
and assigns the result to the print (x)
left operand. Output: 1

**= Exponent AND- Performs C **= A ( is equivalent to C X=4


exponential (power) = C ** A) X **= 4
calculation on operators and print (x)
assigned values to the left Output: 256
operand.

//= Floor Division AND- it C //= A ( is equivalent to C X = 10


performs floor division on = C // A) X //= 3
operators and assign value to print (x)
the left operand. Output: 3

COMPARISON OPERATORS
- Operators that we are using to compare two values or objects. It return either TRUE
or FALSE according to the condition.
- These operators compare the values on either sides of them and decide the relation
among them.
- They are also called RELATIONAL OPERATORS.

TYPES OF COMPARISON OPERATORS

operators Description example

Equal to if the value of two ( X == Y) is not X = 5


(==) operands are equal,then TRUE Y=3
the condition becomes print (x == y)
TRUE Output: False

Not if the value of two ( X != Y) is X=5


Equal to operands are not TRUE Y=3
(!=) equal,then the condition print (x != y)
becomes TRUE Output: True

Greater if the value of left operand ( X > Y) is not X = 15


than (>) is greater than the value of TRUE Y=3
the right operand, then print (x > y)
condition becomes TRUE Output: True
Less if the value of left operand ( X == Y) is X=5
than (<) is less than the value of TRUE Y=3
the right operand, then print (x < y)
condition becomes TRUE Output: False

Greater if the value of left operand ( X >= Y) is not X = 5


than or is greater than or equal to TRUE Y=3
Equal to the value of the right print (x >= y)
(>=) operand, then condition Output: True
becomes TRUE

Less if the value of left operand ( X <= Y) is X=5


than or is less than or equal to the TRUE Y=3
Equal to value of the right operand, print (x <= y)
(<=) then condition becomes Output: False
TRUE

You might also like