Q. 1

What is the output of the following ?

print("78.0 % 3")

Options:

Explanation

Correct answer is : C

"78.0 % 3" is a string type. So will print as it is "78.0 % 3"

Discuss It

Q. 2

What is the precedence of python operators ?
1. Boolean
2. Multiplication
3. Parentheses
4. Subtraction

Options:

Explanation

Correct answer is : D

Python Operator Precedence

  1. Parentheses (grouping)
  2. Function call
  3. Slicing
  4. Subscription
  5. Attribute reference
  6. Exponentiation
  7. Bitwise not
  8. Positive, negative
  9. Multiplication, division, remainder
  10. Addition, subtraction
  11. Bitwise shifts
  12. Bitwise AND
  13. Bitwise XOR
  14. Bitwise OR
  15. Comparisons, membership, identity
  16. Boolean NOT
  17. Boolean AND
  18. Boolean OR
  19. Lambda expression

Discuss It

Q. 3

What is the output of the following code ?

print(243.00 % 4)

Options:

Explanation

Correct answer is : C

243.00 is a float type so 243.00 % 4 will provide remainder as float .i.e. 3.0

Discuss It

Q. 4

What is the output for the following code ?

print(5*2**4)

Options:

Explanation

Correct answer is : B

Exponential operator ** has more precedence than multiplication *
So 2**4 will be evaluated first, resulting in 16
Then 5 * 16 will produce 80 as output

Discuss It

Q. 5

How do you represent or declare Infinity in python ?

Options:

Explanation

Correct answer is : C

Infinity can be declared as float('Inf') or float('-Inf')

Discuss It

Q. 6

What is the output of the following code ?

print(10/9*(4-3) == 10/(9*(4-3)))

Options:

Explanation

Correct answer is : B

Parentheses will be evaluated first.
Here both the right and left side expression will produce 1.1111111111111112
So the final output will be True

Discuss It

Q. 7

What is the output of the following code ?

print(3 ** 4 ** 2)

Options:

Explanation

Correct answer is : C

Expressions with ** is evaluated from right to left
3 ** 4 ** 2 is equivalent to 3 ** (4 ** 2)

Discuss It

Q. 8

What is the output of the following code ?

print(128 / 16 / 2, (128 / 16) / 2, 128 / (16 / 2))

Options:

Explanation

Correct answer is : D

Expressions with "/" is getting evaluated from left to right
128 / 16 / 2 is evaluated as (128 / 16) / 2

Discuss It

Q. 9

What is the output of the following code ?

print(72 // 13 % 7, 72 * 13 // 7)

Options:

Explanation

Correct answer is : C

// and * have same precedence so it will be evaluated left to right.
So 72 // 13 % 7will be evaluated as (72 // 13) % 7and 72 * 13 // 7 as (72 * 13) // 7

Discuss It

Q. 10

What is the output of the following code ?

print(0x78 | 0x23)

Options:

Explanation

Correct answer is : B

"|" is binary OR operator.
So 0x78 converts to 1111000 and 0x23 to 100011 and the bit wise OR operator is performed.

1111000 OR 100011

(1 OR 1) = 1
(1 OR 0) = 1
(1 OR 0) = 1
(1 OR 0) = 1
(0 OR 0) = 0
(0 OR 1) = 1
(0 OR 1) = 1

The above results in 1111011 and prints 123 on console

Discuss It
Submit Your Answers

Interview Questions

on
Introduction

Tutorial

on
Introduction

Programs

on
Introduction
Click any Link
to navigate to certain page easily
Write a line to us
Your Email
Title
Description