7. Evaluate the expression given below if A=16 and B=15.
A%B // A
(a) 0.0
(b) 0
(C) 1.0
(d) 1
Answers
Answer:
A%B= 16%15
Here the remainder is 1
A%B=1
Now 1//A=1//16 which is equal to 0
Hence option (b) is right
The answer will be 0
(b) 0
The python códe will be like this
A = 16
B = 15
print(A % B // A)
Output
0
Explanation
There are two variables which are A and B and the values of these variables are 16 and 15 respectively.
Now, there is an expression in the print statement which is
A % B // A
Put the values of A and B
16 % 15 // 16
(% operator is used to divide the operands and return the remainder)
1 // 16
(// operator is used to divide the operands and will not give the output in float or decimal value even if required. It only gives integer value as output)
0
Extra Information
There are various types of Arithmetic Operators in Python such as
(A) + operator
It is used to add two operands
Example
print(5+3)
The output will be 8
(B) - operator
It is used to subtract two operands
Example
print(5-3)
The output will be 2
(C) * operator
It is used to multiply two operands
Example
print(5*3)
The output will be 15
(D) / operator
It is used to divide the operands and will give the output in float or decimal value if required.
Example
print(5/3)
The output will be 1.6666666666666667
(E) // operator
It is used to divide the operands and will not give the output in float or decimal value even if required. It only gives integer value as output.
Example
print(5//3)
The output will be 1
(F) % operator
It is used to divide the operands and return the remainder
Example
print(5%3)
The output will be 2
(G) ** operator
It is used to raise one operand to the power of another.
Example
print(5**3)
The output will be 125
In mathematical terms, it will be like 5³ which is 125
Python is created by Guido van Rossum and came into existence in 1991. It is a high-level and general programming language. It is a very lucid programming language as it has a good language construct and object-oriented approach. It is dynamically typed and garbage-collected.