Python/Dictionary Python MCQ set 1 Sample Test,Sample questions

Question:
 The following code will return data as ______________

1.List

2.Tuple

3.Dictionary

4.None of the above


Question:
1,2,3 are the ______________ in the following dictionary.
D = {1 : “One”, 2 : “Two”, 3 : “Three”}

1.Keys

2.Values

3.Items

4.None of the above


Question:
A = {“A” : “Apple”, “B” : “Ball”, “C” : “Cat”}
Which of the following statement will return : dict_items([(‘A’, ‘Apple’), (‘B’, ‘Ball’), (‘C’, ‘Cat’)])

1.print(A.keys( ))

2.print(A.values( ))

3.print(A.Items( ))

4.print(A.get( ))


Question:
All elements in dictionary are separated by _________

1.Semicolon(;)

2.Comma( ,)

3.Semicolon(;)

4.dot(.)


Question:
Choose the correct statement
Assertion (A)  : Items in dictionaries are unordered.
Reason (R) : We may not get back the data in the same order in which we had entered the data initially in        
                    the dictionary.

1.A is true but R is false

2.A is false but R is true

3.Both A and R are false

4.Both A and R are true and R is the correct explanation of A


Question:
Choose the correct statement :
Statement A : Dictionaries are mutable.
Statement B : Contents of the dictionary can not changed after it has been created

1.Statement A is True

2.Statement B is True

3.Both the statements are True

4.Statement A is True and Statement B is False


Question:
Dictionaries in python are _______

1.Mutable data type

2.Non-Mutable data type

3.Mapping data type

4.Both a and c


Question:
Dictionary is a ___________ data type.

1.Sequence

2.Mapping

3.Ordered

4.None of the above


Question:
Following statement return values in the form of _______
>>> D1.keys() #D1 is a dictionary

1.tuple

2.list

3.string

4.dictionary


Question:
In dictionary Keys and values are separated by ________________

1.Colon (:)

2.Comma( ,)

3.Semicolon(;)

4.dot(.)


Question:
Key – value concept is in ____

1.List

2.String

3.Dictionary

4.Tuple


Question:
Keys in dictionary are _____________ .

1.Mutable

2.Immutable

3.antique

4.integers


Question:
Keys of dictionary must be _______________

1.antique

2.unique

3.mutable

4.integers


Question:
pop( ) function delete and ____ the element of dictionary.

1.display

2.return

3.not return

4.add


Question:
The following code is an example of _______
N = {A: {'name': 'Ravi', 'age': '5', 'sex': 'M'}, B: {'name': 'Golu', 'age': '2', 'sex': 'F'}}

1.Normal Dictionary

2.Nested Dictionary

3.Empty Dictionary

4.All the above


Question:
The key-value pair in dictionary is called ____

1.item

2.pair item

3.paired value

4.value


Question:
Traversing a dictionary can be done using ____________

1. if statement

2.loop

3.jump statement

4.None of the above


Question:
What type of error is returned by the following code :
a={'a' : "Apple", 'b' : "Banana" , 'c' : "Cat"}
print(a[1])

1.KeyError

2.KeyNotFoundError

3.NotFoundError

4.Syntax Error


Question:
Which function helps to merge dictionary ‘D1’ and ‘D2’?

1.merge( )

2.append( )

3.update( )

4. get( )


Question:
Which of the following are immutable data type?
a. String
b. Tuple
c. List
d. Dictionary

1.a and c

2. b and d

3.a and b

4.c and d


Question:
Which of the following function create a dictionary from a sequence of key-value pairs

1.dictionary( )

2.dict( )

3.create( )

4.convert( )


Question:
Which of the following is an example of dictionary?

1.L = [ ]

2.C = ( )

3.D = { }

4.None of the above


Question:
Which of the following is feature of Dictionary?

1.Keys are unique within a dictionary.

2.Keys are unique within a dictionary.

3.Dictionary is mutable.

4.All of the above


Question:
Which of the following is feature of Dictionary?

1.Keys are unique within a dictionary.

2.Keys are unique within a dictionary.

3.Dictionary is mutable.

4.All of the above


Question:
Which of the following is feature of Dictionary?

1.Keys are unique within a dictionary.

2.Keys are unique within a dictionary.

3.Dictionary is mutable.

4.All of the above


Question:
Which of the following is feature of Dictionary?

1.Keys are unique within a dictionary.

2.Keys are unique within a dictionary.

3.Dictionary is mutable.

4.All of the above


Question:
Which of the following is feature of Dictionary?

1.Keys are unique within a dictionary.

2.Keys are unique within a dictionary.

3.Dictionary is mutable.

4.All of the above


Question:
Which of the following is feature of Dictionary?

1.Keys are unique within a dictionary.

2.Keys are unique within a dictionary.

3.Dictionary is mutable.

4.All of the above


Question:
Which of the following is feature of Dictionary?

1.Keys are unique within a dictionary.

2.Keys are unique within a dictionary.

3.Dictionary is mutable.

4.All of the above


Question:
Which of the following is feature of Dictionary?

1.Keys are unique within a dictionary.

2.Keys are unique within a dictionary.

3.Dictionary is mutable.

4.All of the above


Question:
Which of the following is not method of dictionary?

1.len( )

2.pop( )

3.del ( )

4.update( )


Question:
Which of the following is used to delete an element from Dictionary?

1.pop( )

2.delete

3.remove

4.None of the above


Question:
Which statement is not correct in reference to the following code?
A = {1 : "One", 2 : "Two", 3 : "Three"}
A[4] = "Four"

1.It will add value at the end of dictionary.

2.It will modify value if the key already exist.

3.It will add value in between of the dictionary.

4.All the above


Question:
Which statement is used to create an empty dictionary?
a. 

1.d1 = { }

2.d1 = ( )

3. d1 = dict{ }

4.d1 = [ ]


Question:
Write the output of the following :
A = {"A" : "Apple", "B" : "Ball", "C" : "Cat"}
print(A.get("D"))

1.KeyNotFoundError

2.Name Error

3.Type Error

4.None


Question:
Write the output of the following :
A = {1 : "One", 2 : "Two", 3 : "Three"}
print("One" in A)

1.True

2.False

3.Error

4.One


Question:
Write the output of the following :
d1 = {"a" : 50, "b" : 50}
d2 = {"a" : 500, "b" : 50}
print(d1 > d2)

1.True

2.False

3.Error

4.None of the above


Question:
Write the output of the following code :
A = {1 : "One", 2 : "Two", 3 : "Three"}
B = {'A' : "Apple", 'B' : "Bat", 'C' : "Cat", 'D' : "Doll"}
A.update(B)
#print(B.values())
print(B)

1. {‘A’ : ‘Apple’ , ‘B’ : ‘Bat’ , ‘C’ : ‘Cat’ , ‘D’ : ‘Doll’}

2.{1 : “One” , 2 : “Two” , 3 : “Three”}

3.{1: ‘One’ , 2: ‘Two’ , 3: ‘Three’ , ‘A’: ‘Apple’ , ‘B’: ‘Bat’ , ‘C’: ‘Cat’ , ‘D’: ‘Doll’}

4.None of the above


Question:
Write the output of the following code :
A = {1 : "One", 2 : "Two", 3 : "Three"}
B = {'A' : "Apple", 'B' : "Bat", 'C' : "Cat", 'D' : "Doll"}
print(A.get(4,"Key Not Found"))

1.KeyError

2.Key Not Found

3.None

4.Syntax Error


Question:
Write the output of the following code :
A = {1 : "One", 2 : "Two", 3 : "Three"}
print(A[2] + A[1])

1.Error

2.TwoOne

3.21

4.{1 : “One”, 2 : “Two”, 3 : “Three”}


Question:
Write the output of the following code :
a={'a' : "Apple", 'b' : "Banana" , 'c' : "Cat"}
a['a']="Anar"
print(a)

1.{‘a’: ‘Anar’, ‘b’: ‘Banana’, ‘c’: ‘Cat’}

2.Error

3.{‘a’ : “Apple, ‘a’: ‘Anar’, ‘b’: ‘Banana’, ‘c’: ‘Cat’}

4.None of the above


Question:
Write the output of the following:
A = {1 : "One", 2 : "Two", 3 : "Three"}
B = {'A' : "Apple", 'B' : "Bat", 'C' : "Cat", 'D' : "Doll"}
for i in A:
    print(i)

1.1 2 3

2.1 2 3

3.{1 : “One”, 2 : “Two”, 3 : “Three”}

4.None of the above


Question:
_______ datatype fall under mapping

1.List

2.Tuple

3.Dictionary

4.String


Question:
_______ is the suitable data type for keys of dictionary in python.

1.Number

2.String

3.Tuple

4.All the above


Question:
_________ function returns the number of key: value pairs of the dictionary.

1.total( )

2.len( )

3.length( )

4.items( )


Question:
_________ function returns the value corresponding to the key passed as the argument.

1.get( )

2.values( )

3.update( )

4.update( )


More MCQS

  1. Python MCQS - Function
  2. Python MCQS - GUI in python
  3. Python MCQS - Operators
  4. Python MCQS - Data type in python
  5. Python MCQS - loops in python
  6. Python MCQS - Numpy
  7. Python MCQS - sqlite3
  8. Python MCQS - Library
  9. Python MCQS - Pandas
  10. Python MCQs
  11. Dictionary Python MCQ set 1
  12. Dictionary Python MCQ set 2
  13. MCQ For Python Fundamentals
  14. MCQ Introduction to Python Section 1
  15. MCQ Introduction to Python Section 2
  16. MCQ Introduction to Python Section 3
  17. MCQ on Flow of Control in Python Set 1
  18. MCQ on Flow of Control in Python Set 2
  19. MCQ on Python String Set 1
  20. File Handling in Python section 1
  21. File Handling in Python section 2
  22. Python Functions MCQS Set 1
  23. Python Functions MCQS Set 2
  24. MCQ on List in Python
  25. Pandas MCQ Questions Set 1
  26. Pandas MCQ Questions Set 2
  27. Tuple MCQ in Python
  28. Python dataframe MCQ
  29. Python Mcq Set 1
  30. Python Mcq Set 2
  31. Python Mcq Set 3
  32. Python Mcq Set 4
  33. Python Mcq Set 5
  34. Python Mcq Set 6
  35. Python Mcq Set 7
  36. Python Mcq Set 8
  37. Python Mcq Set 9
  38. Python Mcq Set 10
  39. Python Mcq Set 11
  40. Python Mcq Set 12
  41. Python Mcq Set 13
  42. Python Mcq Set 14
  43. Python Mcq Set 15
  44. Python Mcq Set 16
  45. Python Mcq Set 17
  46. Python Mcq Set 18
  47. Python Mcq Set 19
  48. Python Mcq Set 20
  49. Python Mcq Set 21
  50. Python MCQ
  51. Python MCQ Questions with Answer
  52. Test
  53. python mcq question and answer
Search
Olete Team
Online Exam TestTop Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on Online Exam Testwebsite is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!