Q. 1

What is the output of the following ?

>>> a = 60
>>> b = 90
>>> avg = (a + b) / 2
>>> print(avg)

Options:

Explanation

Correct answer is : B

avg will be converted to float type automatically

Discuss It

Q. 2

Which is not correct expression for a complex number ?

Options:

Explanation

Correct answer is : D

A complex number can be declared as follows
p = complex(8, 9)
p = 8 + 9J
p = 8 + 9j

Discuss It

Q. 3

Which of the following is incorrect syntax ?

Options:

Explanation

Correct answer is : D

float('23' + '89') will be converted to float('2389') results in 2389.0
But "+" in float('23 + 89')can not be converted in float.

Discuss It

Q. 4

Which is of the following results in an error ?

Options:

Explanation

Correct answer is : D

Except Option D, all expression shows explicit conversion.
int('30.0') results in error.

Discuss It

Q. 5

Which of the following results in an error ?

Options:

Explanation

Correct answer is : C

int() base must be >= 2 and <= 36

Discuss It

Q. 6

What is the output of the following code ?

print(bin(0x16))

Options:

Explanation

Correct answer is : A

0x16 represent a hexadecimal number which integer value is 22.
bin(22)converts integer 22 to 10110 and it prints 0b10110 on console

Discuss It

Q. 7

What is the output of the following code ?

5 ^ 2

 

Options:

Explanation

Correct answer is : A

^ is XOR opertor. Both 5 and 2 will be converted to binary format and then the operator being applied on it.

Discuss It

Q. 8

What is the value of a if the following expression is True

a>>2 == 2

 

Options:

Explanation

Correct answer is : C

The value of a will be 8.

When the value of a is equal to 8 (1000), then a>>2 (bitwise right shift) yields the value 0010, which is equal to 2.

Discuss It

Q. 9

What is the output of the following expression ?

>>> ~1001

 

Options:

Explanation

Correct answer is : C

If we have an expression ~X. This is evaluated as: -X – 1.

So -1001 will be evaluated to -1001-1 which is -1002

Discuss It
Submit Your Answers

Interview Questions

on
Data Types

Tutorial

on
Data Types

Programs

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