Python Programming Quiz

Quiz on Arithmetic Operators in Python

Time left: 300 seconds

Q.1. What is the correct operator for (x^y)?

Select Your Option

Here y is in power of x i.e Exponent. Hence, the Power (Exponent) Operator (**) operators is used

Q.2. What is the answer to this expression, 22 % 3 is?

Select Your Option

Modulus operator gives the remainder after dividing the 1st operand by the 2nd operand. So, 22%3 gives the remainder after dividing 22 by 3, that is, 1.

Q.3. Which one of these is floor division?

Select Your Option

// is the floor division operator. When both of the operands are integer then python chops out the fraction part and gives you the round off value, to get the accurate answer use floor division. For ex, 5/2 = 2.5 but both of the operands are integer so answer of this expression in python is 2. To get the 2 as the answer, we use the floor division operator.

Q.4. The expression int(x) implies that the variable x is converted to integer.

Select Your Option

Typecasting/Explicit type conversion of the data type in Python is done by using the built-in functions like int(), float(), str(), etc. The int() returns an integer from a specified object or converts a number of some base to decimal.

Q.5. Operators with the same precedence are evaluated in which manner?

Select Your Option

Precedence of operators is a collection of rules that determine which operators will be evaluated first in an expression. In Python, operators having same precedence are evaluated from left to right.

Q.6. What is the order of precedence in python?
i) Exponential
ii) Multiplication
iii) Parentheses
iv) Division
v) Addition
vi) Subtraction

Select Your Option

For order of precedence, just remember this PEMDAS-Parentheses> Exponential> Multiplication> Division> Addition> Subtraction.

Q.7. What is the output of the following code
          
            x = 6
            y = 2
            print(x ** y, x // y)
          
          

Select Your Option

The Exponent (**) operator performs exponential (power) calculation. so here 6 ** 2 means 6*6 = 36 The // is the Floor Division operator so 6//2=3

Q.8. Which one of the following has the same precedence level?

Select Your Option

“Addition and Subtraction” are at the same precedence level. Similarly, “Multiplication and Division” are at the same precedence level. However, Multiplication and Division operators are at a higher precedence level than Addition and Subtraction operators.

Q.9. What is the output of this expression, 3*1**3?

Select Your Option

First this expression will solve 1**3 because exponential has higher precedence than multiplication, so 1**3 = 1 and 3*1 = 3. Final answer is 3.

Q.10. What is the output of
          
            print(10 - 4 * 2)
          
          

Select Your Option

As (*) precedence is higher than (-) so 4*2 = 8 will be evaluated first and then 10-8 = 2 will be evaluated.

Q.11. What is the output of
          
            print(2%6)
          
          

Select Your Option

Modulus (%) is used to find the remainder if 2 is divided by 6 then the remainder will be 2.

Q.12. What is the output of the expression
          
            print(-18 // 4)
          
          

Select Your Option

In the case of the floor division operator(//), when the result is negative, it is rounded down to the next smallest (big negative) integer.

Q.13. What is the output of
          
            print(2**4 + (5 + 5)**(1 + 1))
          
          

Select Your Option

Here parenthesis () is the highest priority so it executes first and it has left to right associativity. Then ** is used so 16 + 10**2 = 116.

Q.14. What is the value of the expression 100 / 25?

Select Your Option

The result of standard division is always float. Hence, the result of 100/25 is 4.0 whereas the value of 100 // 25 (integer division) is 4.

Q.15. What is the output of
          
            print(2 ** 3 ** 2)
          
          

Select Your Option

We follow left to right evaluation as both operators are same and hence, have same precedence.

Instructions:-

  1. This Quiz is based on Arithmetic Operators in Python
  2. Each correct answer will carry 2 points
  3. Once an option is selected you cannot select any other, So choose wisely
  4. Do not refresh the page as it will reset the quiz
  5. Once the time is up the quiz will automatically get submitted with no of Question responded
  6. Your total score alongwith your name will be shown after submission of the Quiz
  7. Wish you ALL THE BEST 👍👍

START

Results:-

Hi




Post a Comment

FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP

Previous Post Next Post