Python Programming
Python fundamentals to advanced for interviews
56 Questions 10 Topics Take Test
Advertisement
Showing 11–20 of 56 questions
Q.11 Medium Basics & Syntax
What is the output of: print(None == False)?
A True
B False
C None
D Error
Correct Answer:  B. False
EXPLANATION

None and False are distinct objects. None == False evaluates to False. None is a unique singleton object, not equivalent to False or 0.

Take Test
Q.12 Medium Basics & Syntax
Consider the code: x = (1, 2, 3); x[0] = 5. What happens?
A x becomes (5, 2, 3)
B TypeError is raised
C x remains (1, 2, 3)
D IndexError is raised
Correct Answer:  B. TypeError is raised
EXPLANATION

Tuples are immutable. Attempting to modify a tuple element with x[0] = 5 raises a TypeError: 'tuple' object does not support item assignment.

Take Test
Q.13 Medium Basics & Syntax
Consider: d = {'a': 1, 'b': 2}; d['c'] = 3. What is d?
A {'a': 1, 'b': 2}
B {'a': 1, 'b': 2, 'c': 3}
C Error
D None
Correct Answer:  B. {'a': 1, 'b': 2, 'c': 3}
EXPLANATION

Dictionaries are mutable. The assignment d['c'] = 3 adds a new key-value pair to the dictionary. d becomes {'a': 1, 'b': 2, 'c': 3}.

Take Test
Q.14 Medium Basics & Syntax
Consider: x = [1, 2, 3, 4, 5]; y = x[1:4]. What is y?
A [1, 2, 3]
B [2, 3, 4]
C [2, 3, 4, 5]
D [1, 2, 3, 4]
Correct Answer:  B. [2, 3, 4]
EXPLANATION

List slicing x[1:4] includes indices 1, 2, 3 (but excludes 4). Elements are 2, 3, 4 from the list [1, 2, 3, 4, 5].

Take Test
Q.15 Medium Basics & Syntax
Consider the code: def func(x, y=5): return x + y. What is func(3)?
A 3
B 5
C 8
D Error
Correct Answer:  C. 8
EXPLANATION

y has a default value of 5. When func(3) is called, x=3 and y=5 (default). The function returns 3 + 5 = 8.

Take Test
Advertisement
Q.16 Medium Basics & Syntax
Consider: a = 'Hello'; b = 'Hello'. Are a and b the same object?
A Always True
B Always False
C Depends on interpreter implementation
D Cannot be determined
Correct Answer:  C. Depends on interpreter implementation
EXPLANATION

Due to string interning in Python, small strings may be cached and refer to the same object. However, this is an implementation detail. a == b is True, but a is b may vary.

Take Test
Q.17 Medium Basics & Syntax
What will be printed: print(3 ** 2 ** 2)?
A 81
B 512
C 729
D 36
Correct Answer:  A. 81
EXPLANATION

Exponentiation is right-associative. 3 2 2 = 3 (2 2) = 3 ** 4 = 81.

Take Test
Q.18 Medium Basics & Syntax
Consider the code: x = [1, 2, 3]; y = x; y.append(4). What is x?
A [1, 2, 3]
B [1, 2, 3, 4]
C [4]
D Error
Correct Answer:  B. [1, 2, 3, 4]
EXPLANATION

y = x creates a reference to the same list object. When y.append(4) is called, it modifies the original list. Both x and y point to [1, 2, 3, 4].

Take Test
Q.19 Medium Basics & Syntax
What will be the output of: print('abc' * 3)?
A 'abc' 'abc' 'abc'
B 'abcabcabc'
C abcabcabc
D Error
Correct Answer:  C. abcabcabc
EXPLANATION

String multiplication repeats the string. 'abc' * 3 produces 'abcabcabc' and print displays it without quotes.

Take Test
Q.20 Medium Basics & Syntax
Consider: lst = [1, [2, 3], 4]. What is lst[1][0]?
A 1
B 2
C 3
D [2, 3]
Correct Answer:  B. 2
EXPLANATION

lst[1] refers to the nested list [2, 3]. lst[1][0] refers to the first element of that nested list, which is 2.

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