Top 1000+ Solved Problem Solving and Python Programming MCQ Questions Answer

From 481 to 495 of 820

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

a. 1

b. 9

c. 15

d. error

  • c. 15

Q. To shuffle the list(say list1) what function do we use?

a. list1.shuffle()

b. shuffle(list1)

c. random.shuffle(list1)

d. random.shufflelist(list1)

  • c. random.shuffle(list1)

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

  • d. all of the mentioned

Q. Suppose list1 is [2, 33, 222, 14, 25], What is list1[-1]?

a. error

b. none

c. 25

d. 2

  • c. 25

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]

  • a. [2, 33, 222, 14]

Q. >>>print(names[-1][-1])

a. a

b. daman

c. error

d. n

Q. print sum

a. 11

b. 12

c. 21

d. 22

  • b. 12

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]

  • c. [0.0, 0.5, 1.0, 1.5]

Q. >>>list1 < list2 is

a. true

b. false

c. error

d. none

  • b. false

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)

  • b. list1.append(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)

  • b. list1.insert(2, 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”)

  • a. list1.remove(“hello”)
Subscribe Now

Get All Updates & News