Question 1
What is the output of the following code?
my_list = [1, 2, 3, 4, 5]
my_list[1:3] = [10, 20, 30]
print(my_list)
Question 2
Which method is used to remove the last element from a list?
Question 3
What is the output of the following code?
my_list=[1, 2, 3, 4, 5]
new_list=my_list.copy()
new_list[0]=10
print(my_list)
Question 4
How do you add elements from one list to another list?
Question 5
What is the output of the following code?
my_list=[1, 2, 3, 4, 5]
my_list.insert(2, 10)
print(my_list)
Question 6
What is the output of the following code?
my_list=[1, 2, 3, 4, 5]
my_list[1:4]=[10, 20]
print(my_list)
Question 7
Which of the following methods can be used to find the maximum value in a list of numbers?
Question 8
How do you find the number of elements in a list?
Question 9
What dose the count( ) method do in a list?
Question 10
How do you find the first index of a specific element in a list?
Question 11
What is the output of the following code?
my_list = [1, 2, 3]
new_list = my_list * 2
print(new_list)
Question 12
What is the output of the following code?
my_list = [3, 1, 4, 1, 5, 9, 2]
my_list.sort()
print(my_list)
Question 13
What is the purpose of the extend() method in python lists?
Question 14
How do you check if a list is empty?
Question 15
What is the output of the following code?
my_list=[1, 2, 3, 4, 5]
my_list.pop(2)
print(my_list)
Question 16
How do you create an empty list in python?
Question 17
What is the purpose of the reverse( ) method in a list?
Question 18
What is the result of the following code?
my_list = [1, 2, 3]
my_list.append(4)
print(my_list)
Question 19
How do you remove an element from a list without knowing its index?
Question 20
What is the output of the following code?
my_list=[1, 2, 3, 4, 5]
my_list[1:3]=[]
print(my_list)
Question 21
Which method can be used to find the sum of all elements in a list of numbers?
Question 22
What is the output of the following code?
my_list=[1, 2, 3]
my_list.append([4, 5])
print(my_list)
Question 23
Which of the following methods can be used to add an element to the end of a list?
Question 24
Which of the following methods can be used to check if an element is present in a list?
Question 25
Which of the following is a valid way to create a copy of a list?
Question 26
What dose the index( ) method do in a list?
Question 27
How do you check if an element is not present in list?
Question 28
What is the output of the following code?
my_list = [1, 2, 3, 4, 5]
result = my_list.remove(3)
print(result)
Question 29
What is the output of the following code?
my_list=[1, 2, 3, 4, 5]
new_list=my_list[:]
new_list[0]=10
print(my_list)
Question 30
What is the output of the following code?
my_list=[1, 2, 3, 4, 5]
new_list=my_list[::-1]
print(new list)
Question 31
What is the output of the following code?
my_list = [1, 2, 3, 4, 5]
del my_list[2]
print(my_list)
Question 32
How do you find the minimum value in a list of numbers?
Question 33
How do you remove all elements from a list?
Question 34
What happens when you try to access an index that is out of range in a list?
Question 35
What is the output of the following code?
my_list=[1, 2, 3, 4, 5]
my_list.remove(2)
print(my_list)
Question 36
What will the following code output?
my_list = [10, 20, 30, 40, 50]
new_list = my_list[1:4]
print(new_list)
Question 37
What is the output of the following code?
my_list=[1, 2, 3, 4, 5]
my_list.extend([6, 7])
print(my_list)
Question 38
How do you create a list containing the numbers from 0 to 9?
Question 39
Which of the following is a valid way to access the first element of a list?
Question 40
Which method is used to find the index of the last occurrence of a given element in a list?
Question 41
How do you check if two lists are equal in terms of their elements?
Question 42
What is the output of the following code?
my_list = [1, 2, 3, 4, 5]
new_list = my_list
new_list[0] = 10
print(my_list)
Question 43
What is the output of the following code?
my_list=[1, 2, 3, 4, 5]
my_list[1:4]=[10, 20, 30, 40, 50]
print(my_list)
Question 44
Which method is used to insert an element at a specific index in a list?
Question 45
How do you remove the first occurrence of a specific element from a list?
Question 46
What is a list in python?
Question 47
How do you find the second largest element in a list?
Question 48
What is the output of the following code?
my_list=[1, 2, 3, 4, 5]
result=my_list.pop(2)
print(result)
Question 49
What is the output of the following code?
my_list=[1, 2, 3, 4, 5]
my_list.insert(0, 0)
print(my_list)
Question 50
Which of the following methods sorts the elements of a list in ascending order?