Grokking Python Fundamentals
Ask Author
Back to course home

0% completed

Vote For New Content
Quiz
Table of Contents

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible

What is the output of the below code?
numbers = [1, 2, 3, 4, 5]
numbers.append(6)
print(numbers)
A
[1, 2, 3, 4, 5]
B
[1, 2, 3, 4, 5, 6]
C
[6, 1, 2, 3, 4, 5]
D
Error
What is the output of this list comprehension?
a = [1, 2, 3, 4, 5]
b = [x * 2 for x in a]
print(b)
A
[1, 2, 3, 4, 5]
B
[2, 4, 6, 8, 10]
C
[3, 5, 7, 9, 11]
D
Error
What does the pop() method do in a list?
A
Adds an item at the end of the list.
B
Returns the last item and removes it from the list.
C
Sorts the list.
D
Clears the entire list.
What will be the output of the following code]?
words = ["one", "two", "three"]
lengths = [len(word) for word in words]
print(lengths)
A
["one", "two", "three"]
B
[3, 3, 5]
C
["3", "3", "5"]
D
[1, 1, 1]
Which list method adds an item at a specified index?
A
append()
B
extend()
C
add()
D
insert()
What will happen if you try to access an index that does not exist in a list?
numbers = [10, 20, 30]
print(numbers[5])
A
It prints None.
B
It prints 0.
C
It raises an IndexError.
D
It prints the last item in the list.

.....

.....

.....

Like the course? Get enrolled and start learning!

Table of Contents

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible