Data Types MCQs

100 MCQs  (Page 9 of 10)

What does x = {} create in Python?
An empty tuple
An empty set
SyntaxError
An empty dict
What does d = {1: 'a', 1.0: 'b', True: 'c'}; print(d) output?
{True: 'c'}
{1: 'a'}
{1: 'c'}
{1: 'a', 1.0: 'b', True: 'c'}
Given L = [0, 1, 2, 3, 4, 5], what are L[::-2] and L[1:-1:2]?
[5, 3, 1] and [1, 3]
[4, 2, 0] and [1, 3]
[5, 3, 1] and [1, 3, 5]
[0, 2, 4] and [2, 4]
What is the difference between copy.copy and copy.deepcopy in Python?
deepcopy copies only references
copy.copy works only on strings
They are identical
copy.copy duplicates only the outer container; deepcopy recursively copies the nested objects as well