Home Subjects Python Programming

Python Programming

Python fundamentals to advanced for interviews

38 Q 2 Topics Take Mock Test
Advertisement
Difficulty: All Easy Medium Hard 1–10 of 38
Topics in Python Programming
All Basics & Syntax 100 Data Types & Lists 19
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.

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.

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

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.

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.

Test
What will be the output of: x = 5; x += 3; print(x)?
A 5
B 3
C 8
D Error
Correct Answer:  C. 8
EXPLANATION

x += 3 is equivalent to x = x + 3. Starting with x=5, after adding 3, x becomes 8.

Test
What is the output of: print('a' in 'banana')?
A True
B False
C 1
D Error
Correct Answer:  A. True
EXPLANATION

The 'in' operator checks if 'a' is a substring of 'banana'. It is present (multiple times), so it returns True.

Test
What will be the output of: print(10 if 5 > 3 else 20)?
A 10
B 20
C True
D Error
Correct Answer:  A. 10
EXPLANATION

This is a ternary conditional expression. Since 5 > 3 is True, the expression evaluates to 10 (the value before 'if').

Test
What is the output of: print(len('Python'))?
A 5
B 6
C 7
D Error
Correct Answer:  B. 6
EXPLANATION

The string 'Python' has 6 characters: P-y-t-h-o-n. len() returns the number of characters in a string.

Test
Q.10 Easy Basics & Syntax
What will be the data type of x after executing: x = 5 / 2?
A int
B float
C complex
D str
Correct Answer:  B. float
EXPLANATION

In Python 3, the division operator (/) always returns a float, regardless of whether the operands are integers. 5 / 2 = 2.5, which is a float.

Test

About Python Programming Practice on iGET

iGET offers 38+ free Python Programming MCQ questions covering all important topics. Each question is prepared by subject experts and comes with detailed explanations to help you understand concepts deeply, not just memorize answers.

Why prepare with iGET?

100% free access, timed mock tests, instant results with detailed analysis, topic-wise progress tracking, and bookmark feature for revision. Trusted by thousands of aspirants preparing for UPSC, SSC, Bank, Railway, NEET, JEE and other competitive exams across India.

How to use this page effectively

Start by selecting a difficulty level (Easy / Medium / Hard) or pick a specific topic from the topics strip. Attempt questions, check your answer instantly, read the explanation carefully, and bookmark tricky ones for later revision. For full exam-style practice, take a Mock Test from the right sidebar.

IGET
IGET AI
Online · Exam prep assistant
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