➤ How to Code a Game
➤ Array Programs in Java
➤ Java Inline Thread Creation
➤ Java Custom Exception
➤ Hibernate vs JDBC
➤ Object Relational Mapping
➤ Check Oracle DB Size
➤ Check Oracle DB Version
➤ Generation of Computers
➤ XML Pros & Cons
➤ Git Analytics & Its Uses
➤ Top Skills for Cloud Professional
➤ How to Hire Best Candidates
➤ Scrum Master Roles & Work
➤ CyberSecurity in Python
➤ Protect from Cyber-Attack
➤ Solve App Development Challenges
➤ Top Chrome Extensions for Twitch Users
➤ Mistakes That Can Ruin Your Test Metric Program
Q1) To add a new element to a list we use which command?
a) list1.add(5)
b) list1.addEnd(5)
c) list1.append(5)
d) list1.addLast(5)
View Answer
Answer:- c) list1.append(5)We use the function append() to add an element to the list.
Q2) To remove the string “Know Program” from list1, we use which command?
a) list1.remove(Know Program)
b) list1.remove(“Know Program”)
c) list1.removeAll(“Know Program”)
d) list1.removeOne(“Know Program”)
View Answer
Answer:- b) list1.remove(“Know Program”)We use the function remove() to remove an element from the list.
Q3) To insert 3 to the second position in the list1, we use which command?
a) list1.add(2, 3)
b) list1.insert(1, 3)
c) list1.insert(2, 3)
d) list1.append(2, 3)
View Answer
Answer:- b) list1.insert(1, 3)Q4) Suppose list1 is [4, 2, 2, 4, 5, 2, 1, 0], Which of the following is the correct syntax for slicing operation?
a) print(list1[0])
b) print(list1[:2])
c) print(list1[:-2])
d) all of the mentioned
View Answer
Answer:- d) all of the mentionedQ5) Suppose list1 is [2, 33, 222, 14, 25], What is list1[-1]?
a) Error
b) None
c) 25
d) 2
View Answer
Answer:- c) 25[-1] returns the last element in the list.
Q6) 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]
View Answer
Answer:- a) [2, 33, 222, 14][:-1] returns all elements in the list except the last element.
Q7) Suppose list1 is [3, 5, 25, 1, 3], what is min(list1)?
a) 3
b) 5
c) 25
d) 1
View Answer
Answer:- d) 1min() returns the smallest or minimum element in the list.
Q8) Suppose list1 is [5, 50, 1025, 100], what is max(list1)?
a) 35
b) 50
c) 1025
d) 100
View Answer
Answer:- c) 1025max() returns the largest or maximum element in the list.
Q9) Suppose list1 is [1, 3, 2], What is list1 * 2?
a) [2, 6, 4]
b) [1, 3, 2, 1, 3]
c) [1, 3, 2, 1, 3, 2]
d) [1, 3, 2, 3, 2, 1]
View Answer
Answer:- c) [1, 3, 2, 1, 3, 2]Q10) Suppose list1 is [1, 5, 9], what is sum(list1)?
a) 1
b) 9
c) 15
d) Error
View Answer
Answer:- c) 15sum() returns the sum of all elements in the list.
Also See:- MCQ on List in Python– 3