wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python Lists Quiz 1

Total questions: 80

Worksheet time: 40mins

Name
Class
Date
1.

Which of the following operations can be performed on lists in Python?

a)

Concatenation, repetition, membership, slicing

b)

Traversing a list using loops

c)

Built-in functions like len(), append(), and remove()

d)

All of the above

2.

What does the `len()` function do when applied to a list in Python?

a)

It removes an element from the list

b)

It returns the length of the list

c)

It sorts the list in ascending order

d)

It appends an element to the list

3.

Which method is used to add an element to the end of a list in Python?

a)

append()

b)

insert()

c)

extend()

d)

pop()

4.

What is the purpose of the `pop()` method in Python lists?

a)

To add an element to the list

b)

To remove and return the last element of the list

c)

To count the number of occurrences of an element in the list

d)

To reverse the order of the list

5.

Which of the following methods can be used to sort a list in Python?

a)

reverse()

b)

sorted()

c)

sort()

d)

Both B and C

6.

What is the difference between `sort()` and `sorted()` in Python?

a)

`sort()` returns a new list, while `sorted()` modifies the original list

b)

`sort()` modifies the original list, while `sorted()` returns a new list

c)

Both modify the original list

d)

Both return a new list

7.

Which method is used to count the frequency of an element in a list?

a)

count()

b)

index()

c)

remove()

d)

sum()

8.

What is the purpose of the `index()` method in Python lists?

a)

To find the position of an element in the list

b)

To remove an element from the list

c)

To add an element to the list

d)

To reverse the order of the list

9.

Which of the following is NOT a built-in method for Python lists?

a)

append()

b)

extend()

c)

multiply()

d)

insert()

10.

What is the result of the operation `list1 + list2` in Python?

a)

It concatenates list1 and list2

b)

It multiplies the elements of list1 and list2

c)

It removes duplicates from list1 and list2

d)

It reverses the order of list1 and list2

11.

Which of the following operations can be used to traverse a list in Python?

a)

Using a for loop

b)

Using a while loop

c)

Using list comprehension

d)

All of the above

12.

What is the purpose of slicing in Python lists?

a)

To remove elements from the list

b)

To access a subset of elements from the list

c)

To sort the list

d)

To reverse the list

13.

Which method is used to reverse the order of elements in a Python list?

a)

reverse()

b)

sort()

c)

append()

d)

pop()

14.

What is a nested list in Python?

a)

A list that contains only numeric values

b)

A list that contains another list as an element

c)

A list that is sorted in ascending order

d)

A list that is empty

15.

Which of the following programs can be implemented using Python lists?

a)

Finding the maximum value in a list

b)

Finding the mean of numeric values in a list

c)

Counting the frequency of elements in a list

d)

All of the above

16.

What is the result of the operation `list1 * 3` in Python?

a)

It multiplies all elements of list1 by 3

b)

It repeats the elements of list1 three times

c)

It removes duplicates from list1

d)

It reverses the order of list1

17.

Which method is used to add multiple elements to a list in Python?

a)

append()

b)

extend()

c)

insert()

d)

pop()

18.

What is the purpose of the `min()` function in Python lists?

a)

To find the smallest element in the list

b)

To find the largest element in the list

c)

To calculate the sum of all elements in the list

d)

To count the number of elements in the list

19.

Which of the following is a valid way to find the mean of numeric values in a Python list?

a)

Using the sum() function and dividing by the length of the list

b)

Using the max() function

c)

Using the min() function

d)

Using the reverse() function

20.

What is the purpose of a linear search on a list in Python?

a)

To find the maximum value in the list

b)

To find the minimum value in the list

c)

To search for an element in the list sequentially

d)

To sort the list in ascending order

21.

Which method is used to remove an element from a specific position in a Python list?

a)

remove()

b)

pop()

c)

insert()

d)

index()

22.

What is the result of the operation `list1[1:4]` in Python?

a)

It returns the first four elements of list1

b)

It returns elements from index 1 to index 4 (excluding index 4)

c)

It removes elements from index 1 to index 4

d)

It reverses the order of elements from index 1 to index 4

23.

Which method is used to insert an element at a specific position in a Python list?

a)

append()

b)

insert()

c)

extend()

d)

pop()

24.

Which of the following is a valid way to check if an element exists in a Python list?

a)

Using the `in` keyword

b)

Using the `not` keyword

c)

Using the `append()` method

d)

Using the `remove()` method

25.

What is the result of the operation `list1.remove(3)` in Python?

a)

It removes the element at index 3

b)

It removes the first occurrence of the value 3 in the list

c)

It removes all occurrences of the value 3 in the list

d)

It removes the last element of the list

26.

Which of the following is a valid way to find the maximum value in a Python list?

a)

Using the max() function

b)

Using the min() function

c)

Using the sum() function

d)

Using the reverse() function

27.

What is the purpose of the `remove()` method in Python lists?

a)

To remove the last element of the list

b)

To remove the first occurrence of a specified value from the list

c)

To remove all elements from the list

d)

To remove elements from a specific index

28.

Which of the following operations can be used to find the frequency of elements in a Python list?

a)

Using the count() method

b)

Using a for loop

c)

Using a linear search

d)

All of the above

29.

What is the result of the operation `list1[-1]` in Python?

a)

It returns the first element of the list

b)

It returns the last element of the list

c)

It removes the last element of the list

d)

It returns the length of the list

30.

Which of the following is a valid way to find the sum of numeric values in a Python list?

a)

Using the sum() function

b)

Using the max() function

c)

Using the min() function

d)

Using the reverse() function

31.

What is the result of the operation `list1.append(5)` in Python?

a)

It returns the last element of list1

b)

It sorts the list1 in ascending order

c)

It removes the element 5 from list1

d)

It adds the element 5 to the end of list1

32.

Which method is used to remove all elements from a Python list?

a)

delete()

b)

pop()

c)

remove()

d)

clear()

33.

What does the `sorted()` function do when applied to a list in Python?

a)

It sorts the list in place and returns None

b)

It reverses the order of the list

c)

It sorts the list in ascending order and returns a new list

d)

It removes duplicates from the list

34.

Which method is used to remove the first occurrence of a specific element from a Python list?

a)

delete()

b)

clear()

c)

remove()

d)

pop()

35.

What does the `count()` method do in Python lists?

a)

Counts the number of unique elements in the list

b)

Counts the number of even elements in the list

c)

Counts the total number of elements in the list

d)

Counts the number of occurrences of a specific element

36.

Which of the following is a valid way to concatenate two lists in Python?

a)

Using the extend() method

b)

Both A and C

c)

Using the + operator

d)

Using the append() method

37.

What is the result of the operation `list1 + list2` in Python?

a)

It slices list1

b)

It concatenates list1 and list2

c)

It checks membership of list2 in list1

d)

It repeats list1

38.

How can you check if an element is a member of a list in Python?

a)

Using the `in` keyword

b)

Using the `find()` method

c)

Using the `membership()` function

d)

Using the `exists()` method

39.

What does the operation `list1 * 3` do in Python?

a)

It slices list1 into three parts

b)

It repeats the elements of list1 three times

c)

It concatenates list1 three times

d)

It checks if 3 is a member of list1

40.

Which of these is the best description of a list in Python?

a)

A list is a collection of data that has an order and can be changed

b)

A list is a lot of variables

c)

A list is used for shopping

d)

A list is a collection of data that cannot hold duplicated data and cannot be changed

41.

Which of these is the correct code for creating a list of names?

a)

nameList = John, Harry, Jesse, John, Harry, Harry

b)

nameList = ("John", "Harry", "Jesse", "John", "Harry", "Harry")

c)

nameList = ["John", "Harry", "Jesse", "John", "Harry", "Harry"]

d)

nameList = [John, Harry, Jesse, John, Harry, Harry]

42.

List items have an index number. In the following list, which item has the index number of 3?

["John", "Harry", "Jesse", "John", "Harry", "Harry"]

a)

"John"

b)

"Harry"

c)

"Jesse"

43.

Which of these pieces of code would return the name "Harry" from the following list?

nameList = ["John", "Harry", "Jesse", "John", "Harry", "Harry"]

a)

nameList()

b)

nameList[1]

c)

NameList(4)

d)

nameList["4"]

44.

Which of these codes is correct for creating a list of numbers?

a)

num = ('10','29','37','109')

b)

num = ['10','29','37','109']

c)

num == ('10','29','37','109')

d)

num = ['10 29 37 109']

45.

How do i remove something from a list?

a)

variable.append()

b)

variable.delete()

c)

variable.remove()

d)

variable=(new variable)

46.

Which code would i use to add an item to a list?

a)

variable.add()

b)

variable.append()

c)

append.variable()

d)

add.variable()

47.

What is used to separate elements in a list?

a)

Bracket

b)

Comma

c)

Full Stop

d)

Space

48.

variable.sort() will do what?

a)

Sort the list into alphabetical order

b)

Sort the list into reverse order

c)

Create a new list

d)

Error

49.

What does the '#' allow you to do?

a)

Repeat code

b)

Comment on code

c)

Print code

d)

End code

50.

An empty list can be declared as

a)

fruitList = ""

b)

fruitList = ["empty"]

c)

fruitList == []

d)

fruitList = []

51.

Each item in a list has an "address" or index. The first index in a Python list is what?

a)

1

b)

0

c)

a

d)

A

52.

In programming, lists are often known as...

a)

Arrays

b)

Elements

c)

Indexes

d)

Data

53.

What is the output of the following?

x = ['ab', 'cd']

for i in x:

i.upper()

print(x)

a)

[‘ab’, ‘cd’].

b)

[‘AB’, ‘CD’].

c)

None of the above

d)

[None, None]

54.

Which of the following commands will create a list?

a) list1 = list()

b) list1 = [].

c) list1 = list([1, 2, 3])

d) all of the mentioned

a)

list1 = list()

b)

list1 = [].

c)

list1 = list([1, 2, 3])

d)

all of the mentioned

55.

Suppose list1 is [3, 5, 25, 1, 3], what is min(list1) ?

a)

3

b)

5

c)

1

d)

25

56.

Suppose list1 is [1, 5, 9], what is sum(list1) ?

a)

1

b)

9

c)

15

d)

none

57.

What will be the output?

names1 = ['Amir', 'Bala', 'Chales']

if 'amir' in names1:

print(1)

else: print(2)

a)

None

b)

1

c)

2

d)

error

58.

Which of the following is the correct way to add the number 4 to mylist?

a)

mylist + 4

b)

mylist.append(4)

c)

mylist.append([4])

d)

4.append(mylist)

59.

Which of the following commands will return the length of the list mylist?

a)

length(mylist)

b)

len(mylist)

c)

mylist.length()

d)

mylist.len()

60.

Which would be the correct code to access number 10

a)

list_2d[3][4]

b)

list_2d= [2,3]

c)

list_2d[2][3]

d)

list_2d(0,0)

61.

A two-dimensional array Array_2d consists of data: [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12]]. What is the output of print(Array_2d[1][1])?

a)

1

b)

2

c)

5

d)

6

62.

An empty list can be declared as

a)

fruitList = ""

b)

fruitList = ["empty"]

c)

fruitList == []

d)

fruitList = []

63.

Write the output of the following code :

L=[“Amit”,”Sumit”,”Naina”]

L1=[“Sunil”]

print(L + L1)

a)

a. [‘Amit’ , ‘Sumit’ , ‘Naina’ , [‘Sunil’]]

b)

b. [‘Amit’ , ‘Sumit’ , ‘Naina’ , ‘Sunil’]

c)

c. List can not concatenate

d)

d. None of the above

64.

Result of list slice is also a list?(T/F)

a)

a. True

b)

b. False

65.

What is the output of the code above

a)

AA-B-CBA-B-CC

b)

A-B-CAA-B-CBA-B-C

c)

AA-B-CBA-B-CC

d)

AA-B-CBA-B-CCA-B-C

66.

What is the output of the code above

a)

10

b)

20

c)

30

d)

40

67.

Who developed Python Programming Language?

a)

a) Wick van Rossum

b)

b) Rasmus Lerdorf

c)

c) Guido van Rossum

d)

d) Niene Stom

68.

What will be the output of the following Python statement?

>>>"abcd"[2:]

a)

a) a

b)

b) ab

c)

c) cd

d)

d) dc

69.

If a=(1,2,3,4), a[1:-1] is _________

a)

a) Error, tuple slicing doesn’t exist

b)

b) [2,3]

c)

c) (2,3,4)

d)

d) (2,3)

70.

What is the result of the following operation in Python: 'del my_list[2]'?

a)

It deletes the third element from 'my_list'

b)

It deletes the second element from 'my_list'

c)

It clears the entire list 'my_list'

d)

It appends the number 2 to 'my_list'

71.

What is the output of this code snippet?

(a)  

72.

What is the output of this code snippet?

(a)  

73.

How can you extract every second element from a list using slicing?

a)

list[1::2]

b)

list[::2]

c)

list[2:]

d)

list[::3]

74.

What happens if you try to slice a list with an out-of-range index?

a)

Slicing a list with an out-of-range index returns the last element of the list.

b)

Slicing a list with an out-of-range index returns the original list.

c)

Slicing a list with an out-of-range index returns an empty list.

d)

Slicing a list with an out-of-range index raises an IndexError.

75.

veggies = ['carrot', 'broccoli', 'potato', 'asparagus'] veggies.insert(veggies.index('broccoli'), 'celery') print(veggies)

a)

[‘carrot’, ‘celery’, ‘broccoli’, ‘potato’, ‘asparagus’]

b)

[‘carrot’, ‘celery’, ‘potato’, ‘asparagus’]

c)

[‘carrot’, ‘broccoli’, ‘celery’, ‘potato’, ‘asparagus’]

d)

[‘carrot’, ‘broccoli’, ‘celery’, ‘potato’, ‘asparagus’]

76.

To insert 5 to the third position in list1, we use which command?

a)

list1.insert(3, 5)

b)

list1.insert(2, 5)

c)

list1.add(3, 5)

d)

list1.append(3, 5)

77.

Suppose list1 is [3, 4, 5, 20, 5], what is list1.index(5)?

a)

0

b)

1

c)

4

d)

2

78.

What is the output when we execute list(“hello”)?

a)

[‘h’, ‘e’, ‘l’, ‘l’, ‘o’]

b)

[‘hello’]

c)

[‘hello’]

d)

None of the Above

79.

Which list comprehension creates a list of even numbers from 1 to 10?

a)

[x for x in range(1, 11) if x % 2 == 0]

b)

[x for x in range(1, 11) if x % 2 != 0]

c)

[x for x in range(2, 11, 2)]

d)

[x * 2 for x in range(1, 6)]

80.

What's the output of this conditional list comprehension? [x if x < 3 else 10 for x in range(5)]

a)

[0, 1, 2, 3, 4]

b)

[0, 1, 2, 10, 10]

c)

[10, 10, 10, 3, 4]

d)

[0, 1, 2, None, None]