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

From 46 to 60 of 820

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”)

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]

  • 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”

  • a. [“welcome”, “to”, “python”]

Q. >>>list("a#b#c#d".split('#'))

a. [‘a’, ‘b’, ‘c’, ‘d’]

b. [‘a b c d’] c) [‘a#b#c#d’]

  • a. [‘a’, ‘b’, ‘c’, ‘d’]
Subscribe Now

Get All Updates & News