Q. 1

Keys of a dictionary must be

Options:

Explanation

Correct answer is : D

Hash table implimantation of dictionary uses hash values of key to get the key. If the key will mutable then its value colud be changed, which will affect the hash value.

Discuss It

Q. 2

Which is correct ?

Options:

Explanation

Correct answer is : D

Python also includes a data type for sets. A set is an unordered collection with no duplicate elements. Basic uses include membership testing and eliminating duplicate entries. Set objects also support mathematical operations like union, intersection, difference, and symmetric difference.

Discuss It

Q. 3

What is the output of the following code ?

>>> type({5})

Options:

Explanation

Correct answer is : C

Curly braces or the set() function can be used to create sets
basket = {'apple', 'orange', 'apple', 'pear', 'orange', 'banana'}
Here basket is a set

Discuss It

Q. 4

What is the data type of the following obj?

obj = [ 10.2, "Hello", 45, {7, 9 }]

Options:

Explanation

Correct answer is : A

List can be created by putting comma separated values (objects) between square brackets ' [ ] '

Discuss It

Q. 5

To store data in key value pairs which data type is used ?

Options:

Explanation

Correct answer is : B

Dictionary data type is used to store value in key value pair
Example:

dict_name = {"name": "python easy"}

Discuss It

Q. 6

Which of the following is not a data type ?

Options:

Explanation

Correct answer is : C

The following are the core data types of python

  • list
  • tuple
  • set
  • dict
  • int
  • float
    and more ...

class is a keyword in python

Discuss It

Q. 7

What is the output of the following code ?

print(bool())
print(bool('False'))

Options:

Explanation

Correct answer is : B

bool()- always results in False
'False' is a truth value of string type , bool(True)will result in True

Discuss It

Q. 8

What is the output of the following code ?

p = [3, 4, 5][bool(0)]
print(p)

Options:

Explanation

Correct answer is : A

bool(0) results in False
Then [3, 4, 5][False] is [3, 4, 5][0], which will result in 3 as output

Discuss It

Q. 9

What is the output of the following code ?

print(not(7 & 7))
print(not(9 > 4))

Options:

Explanation

Correct answer is : D

7 & 7 results in 7 . Here 7 is true value of integer type if considered for boolean. so not(7) results in False
9 > 4results in True and not(True)results in False

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