Arithmetic Operators in Python
What are Operators ?
Operators are special symbols which perform a special task on values or variables. Same operator can behave differently on different data types.
What do you mean by Operand?
Operands are the values or variables on which the operator operate.
What do you mean by Expression in python?
Operators when applied on operands form an expression. for example
a = c – d
Identify the operator and operand in the following expression.
1) d = a * b
Here d, a, b are operands and = , * are operators
2) c = a + b
Here c, a, b are operands and =, + are operators
Operators are categorized as
1. Arithmetic
2. Relational
3. Logical
4. Assignment
Arithmetic / Mathematical Operators
Those operators which perform mathematical calculation are called Arithmetic / Mathematical Operators.
Symbol | Name | Coding | Output |
+ | Addition | >>> 6 + 9 >>> ‘CS’ + ‘IP’ >>> 2.4 + 5 >>>3.5 + 2.5 >>> 2.5 + ‘CS’ | 15 CSIP 7.4 6.0 TypeError |
– | Subtraction | >>> 9 – 2 >>> 7.5 – 2 >>> 10.6 – 5.6 | 7 5.5 5.0 |
* | Multiplication | >>> 2 * 6 >>> 5.2 * 2 >>> 2.5 * 2.5 >>> “Hello” * 2 >>> 2 * “Hello” | 12 10.4 6.25 HelloHello HelloHello |
/ | Division | >>> 7 / 2 >>> 7.0 / 2 >>> 7.0 / 2.0 | 3.5 3.5 3.5 |
% | Remainder | >>> 7 % 2 >>> 2 % 5 >>> 7.2 % 2.0 | 1 2 1.2 |
** | Exponentiation | >>> 2 ** 3 >>> 2.0 * 3.0 >>> 2.0 ** 3 | 8 8.0 8.0 |
// | Integer Division | >>> 7 // 2 >>> 8.5 // 2 | 3 4.0 |
Q1. Evaluate the following Expressions
a) 2 + 3//4 -7
Ans. -5
b) 45 %6 **1 *4
Ans. 12
c) 45 – 9**2 % 15
Ans. 39
d) “CS” ** 10%3
Ans. Error
e) 79 – 3*4 +6 // 2
Ans. 70
f) 35 / 45 // 7
Ans. 0.0
g) 3 + 4 – 7 + 6 %2
Ans. 0
h) 2 % 7 + 9 // 2
Ans. 6
i) 35 * 2 ** 2
Ans. 140
j) 95 – 100 % 99 – 7 **2
Ans. 45
Q2. Name a mathematical operator in python which returns the remainder.
Ans. Modulus (%)
Q3. What is the difference between * and ** ?
Ans. * operator returns the product of two numbers for example 2 * 3 returns 6. ** operator returns the exponent of one number to other for example 2 ** 3 returns 8.
Disclaimer : I tried to give you the correct explanation of “Arithmetic Operators in Python ” , but if you feel that there is/are mistakes in the explanation of “Arithmetic Operators in Python “ given above, you can directly contact me at csiplearninghub@gmail.com.
Class 12 Computer Science Sample Paper 2020-2021.
Class 12 Computer Science Sample Paper Marking Scheme
Class 12 Computer Science Test Series