Font size
WorksheetsPython Dictionary,Tuple and set
Total questions: 35
Worksheet time: 18mins
The code snippet above outputs
error
None
NaN
-1
What is the output of the code above
None
Syntax Error
-1
Code doesn't compile
The output of the code above is
Key Error
4
Math
The code above prints
Math
Physics
Chemistry
English
4
3.8
3.6
3.7
None
None
None
None
NaN
NaN
NaN
NaN
What is the output of the program above
e
y
t
g
The output of the code above is
[101, 102, 103, 104]
[3.6, 3.7, 3.8, 4]
What is the output of the code above
[3.6, 3.7, 3.8, 4]
[101, 102, 103, 104]
Assume the key is the student's id and the value is the grade. Which of the following code will get the grade of student id 102.
grades[102]
grades.get(102)
grades[2]
grades[3]
grades.key(102)
Which of the following are valid ways to create a dictionary like this
Which of the following code deletes the key 103 and its value
del grades[103]
grades.pop(103)
del grades["103"]
grades.pop("103")
What is the output of the code above
3.9
4
Syntax error
What is the output of the program above
7
6
5
9
4
How to fix the syntax error above ?
grades.pop("Science", None)
grades.pop["Science","None"]
del grades["Math"]
del grades["Math", None]
What is the problem with the code above ?
Dictionary cannot be changed during an iteration
This code will run fine (without syntax errors)
After all the grades are popped, there are no elements remaining. The print statement will throw a syntax error.
Tuples in Python are mutable
False
True
How to create a single element tuple
(1,)
(1)
{1}
[1]
tuple([1])
Result of the program above is
('1', '2', '3', '4', '5')
(1, 2, 3, 4, 5)
12345
"12345"
What is the output of the program above
<class 'tuple'>
<class 'None'>
<class 'list'>
<class 'int'>
What is the output of the code above
(1, '2', 3, 4, 5)
syntax error
(1, 2, 3, 4, 5)
('1', '2', '3', '4', '5')
Which of the following is true
a is assigned a value of 1
b is assigned a value of [2,3]
b is assigned a value of (2,3)
b is assigned a value of 2
What is the output of the program above ?
b is bigger
a is bigger
Syntax error : tuples can't be compared
What is the output of the code above ?
1 4
1
1 None
1 [2,3,4]
1 (2,3,4)
What is the output of the program above ?
True
False
Which of the following is used to define a block of code in Python language?
Key
Indentation
Brackets
All of the mentioned
What will be the value of the following Python expression?4 + 3 % 5
2
7
1
4
Is Python code compiled or interpreted?
Python code is both compiled and interpreted
Python code is neither compiled nor interpreted
Python code is only interpreted
Python code is only compiled
Which keyword is used for function in Python language?
Function
Fun
Define
def
Which of the following is the correct extension of the Python file?
.pl
.py
.pl
p
What will be the type of the variable sorted_numbers in the below code snippet?
numbers = (4, 7, 19, 2, 89, 45, 72, 22)
sorted_numbers = sorted(numbers)
print(sorted_numbers)
list
tuple
string
int
What is the output of the following code snippet ?
2 2
error
2 3
None of the above
Which one of the following is the correct output of the following code snippet?
[1] [2] [3]
[1, 2, 3]
[1] [1, 2] [1, 2, 3]
None of the above
What is the output of the following code snippet ?
1
2
error
None of the above
Which of these is the definition for packages in Python
A set of programs making use of Python modules
A set of main modules
A folder of python modules
A set of programs making use of Python modules
Which of the following functions is a built-in function in python?
sqrt()
factorial()
print()
seed()
What does pip stand for python?
Preferred Installer Program
Pip Installs Python
Pip Installs Packages
All of the mentioned
