Python Programming
Python fundamentals to advanced for interviews
119 Questions 10 Topics Take Test
Advertisement
Showing 101–110 of 119 questions
Q.101 Easy Basics & Syntax
Which of the following keywords is used to create a function in Python?
A function
B def
C func
D define
Correct Answer:  B. def
EXPLANATION

The 'def' keyword is used to define a function in Python. Other options are not valid Python keywords.

Take Test
Q.102 Easy Basics & Syntax
What will be the output of: print(type(5 / 2))?
A
B
C
D
Correct Answer:  B.
EXPLANATION

The division operator (/) in Python 3 always returns a float, even if both operands are integers.

Take Test
Q.103 Hard Basics & Syntax
Which of the following will raise an IndexError?
A lst = [1, 2, 3]; lst[2]
B lst = [1, 2, 3]; lst[3]
C lst = [1, 2, 3]; lst[-1]
D lst = [1, 2, 3]; lst[0]
Correct Answer:  B. lst = [1, 2, 3]; lst[3]
EXPLANATION

A list with 3 elements has valid indices 0, 1, 2. Index 3 is out of range and raises IndexError.

Take Test
Q.104 Medium Basics & Syntax
What will be the output of: 'a' in 'apple'?
A True
B False
C 1
D Error
Correct Answer:  A. True
EXPLANATION

The 'in' operator checks for substring presence. 'a' is in 'apple', so it returns True.

Take Test
Q.105 Easy Basics & Syntax
Which statement about Python comments is correct?
A Comments must be on their own line
B Comments start with # and can be inline or on separate lines
C Comments use // like in C++
D Multiple line comments use /* */
Correct Answer:  B. Comments start with # and can be inline or on separate lines
EXPLANATION

Python comments start with # and can appear anywhere. Multi-line comments use triple quotes or multiple # symbols.

Take Test
Advertisement
Q.106 Hard Basics & Syntax
What will be the output of:
x = [1, 2, 3]
y = x
x.append(4)
print(y)
A [1, 2, 3]
B [1, 2, 3, 4]
C Error
D None
Correct Answer:  B. [1, 2, 3, 4]
EXPLANATION

y = x creates a reference to the same list, not a copy. When x is modified, y reflects the changes.

Take Test
Q.107 Hard Basics & Syntax
What is the output of: print(2 ** 3 ** 2)?
A 512
B 64
C 256
D 8
Correct Answer:  A. 512
EXPLANATION

The operator is right-associative. So 2 3 2 = 2 (3 2) = 2 9 = 512.

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

append() adds the entire list [4, 5] as a single element. So x becomes [1, 2, 3, [4, 5]] with length 4.

Take Test
Q.109 Medium Basics & Syntax
Which of the following is a mutable data type in Python?
A String
B Integer
C List
D Tuple
Correct Answer:  C. List
EXPLANATION

Lists are mutable, meaning their elements can be changed after creation. Strings, integers, and tuples are immutable.

Take Test
Q.110 Medium Basics & Syntax
What will be the output of: 'Hello' * 2?
A 'HelloHello'
B Error
C 'Hello' concatenated twice
D HelloHello
Correct Answer:  D. HelloHello
EXPLANATION

String multiplication repeats the string. 'Hello' * 2 produces 'HelloHello'.

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