Python Programming — Data Types & Lists
Python fundamentals to advanced for interviews
5 Questions 10 Topics Take Test
Advertisement
Showing 1–5 of 5 questions in Data Types & Lists
What will be the output?
my_list = [1, 2, 3, 4, 5]
print(my_list[1:3])
A [1, 2]
B [2, 3]
C [2, 3, 4]
D [3, 4]
Correct Answer:  B. [2, 3]
EXPLANATION

List slicing [1:3] returns elements from index 1 (inclusive) to index 3 (exclusive), which are elements at positions 1 and 2.

Take Test
Which method removes and returns the last element from a list?
A remove()
B pop()
C delete()
D discard()
Correct Answer:  B. pop()
EXPLANATION

pop() removes and returns the last element (or element at specified index). remove() only removes value, doesn't return it.

Take Test
What will be the type of x after executing: x = [1, 2.5, 'hello']?
A list
B mixed
C tuple
D dict
Correct Answer:  A. list
EXPLANATION

Square brackets [] create a list object. Lists in Python can contain elements of different data types (heterogeneous).

Take Test
Which of the following is NOT a valid Python data type?
A int
B string
C list
D tuple
Correct Answer:  B. string
EXPLANATION

In Python, the string data type is represented as 'str', not 'string'. 'string' is not a built-in data type.

Take Test
What will be the output of the following code?
my_list = [1, 2, 3]
my_list.append(4)
print(len(my_list))
A 4
B 3
C 5
D Error
Correct Answer:  A. 4
EXPLANATION

append() adds one element to the list. Initial length is 3, after append(4) it becomes 4.

Take Test
IGET
iget AI
Online · Ask anything about exams
Hi! 👋 I'm your iget AI assistant.

Ask me anything about exam prep, MCQ solutions, study tips, or strategies! 🎯
UPSC strategy SSC CGL syllabus Improve aptitude NEET Biology tips