Top 1000+ Solved Problem Solving and Python Programming MCQ Questions Answer
Q. Suppose list1 is [4, 2, 2, 4, 5, 2, 1, 0], Which of the following is correct syntax for slicing operation?
a. print(list1[0])
b. print(list1[:2])
c. print(list1[:-2])
d. all of the mentioned
Q. Suppose list1 is [2, 33, 222, 14, 25], What is list1[:-1]?
a. [2, 33, 222, 14]
b. error
c. 25
d. [25, 14, 222, 33, 2]
Q. Suppose list1 = [0.5 * x for x in range(0, 4)], list1 is:
a. [0, 1, 2, 3]
b. [0, 1, 2, 3, 4]
c. [0.0, 0.5, 1.0, 1.5]
d. [0.0, 0.5, 1.0, 1.5, 2.0]
Q. To add a new element to a list we use which command?
a. list1.add(5)
b. list1.append(5)
c. list1.addlast(5)
d. list1.addend(5)
Q. 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)
Q. To remove string “hello” from list1, we use which command?
a. list1.remove(“hello”)
b. list1.remove(hello)
c. list1.removeall(“hello”)
d. list1.removeone(“hello”)
Q. Suppose list1 is [3, 4, 5, 20, 5, 25, 1, 3], what is list1 after list1.reverse()?
a. [3, 4, 5, 20, 5, 25, 1, 3]
b. [1, 3, 3, 4, 5, 5, 20, 25]
c. [25, 20, 5, 5, 4, 3, 3, 1]
d. [3, 1, 25, 5, 20, 5, 4, 3]
Q. >>>"Welcome to Python".split()
a. [“welcome”, “to”, “python”]
b. (“welcome”, “to”, “python”)
c. {“welcome”, “to”, “python”}
d. “welcome”, “to”, “python”