Python Programming
Python fundamentals to advanced for interviews
119 Questions 10 Topics Take Test
Advertisement
Showing 81–90 of 119 questions
Q.81 Easy Basics & Syntax
What will be the output of: x = 5; y = 10; print(x == y)
A True
B False
C Error
D None
Correct Answer:  B. False
EXPLANATION

The comparison operator == checks if x equals y. Since 5 ≠ 10, the result is False.

Take Test
Q.82 Easy Basics & Syntax
Which of the following statements about Python tuples is correct?
A Tuples are mutable and can be modified after creation
B Tuples are immutable and cannot be modified after creation
C Tuples use square brackets for declaration
D Tuples automatically convert to lists when assigned
Correct Answer:  B. Tuples are immutable and cannot be modified after creation
EXPLANATION

Tuples are immutable sequences in Python, meaning their contents cannot be changed once created.

Take Test
Q.83 Easy Basics & Syntax
What is the correct way to create a dictionary in Python?
A d = {1: 'a', 2: 'b'}
B d = [1: 'a', 2: 'b']
C d = (1: 'a', 2: 'b')
D d = {1; 'a'; 2; 'b'}
Correct Answer:  A. d = {1: 'a', 2: 'b'}
EXPLANATION

Dictionaries in Python use curly braces with key-value pairs separated by colons.

Take Test
Q.84 Hard Basics & Syntax
What will be the output of: print({1, 2, 3} | {3, 4, 5})?
A {1, 2, 3, 3, 4, 5}
B {1, 2, 3, 4, 5}
C {3}
D {1, 2, 4, 5}
Correct Answer:  B. {1, 2, 3, 4, 5}
EXPLANATION

The | operator performs set union, combining all unique elements from both sets. Result is {1, 2, 3, 4, 5}.

Take Test
Q.85 Hard Basics & Syntax
Consider the following code:
x = [1, 2, 3]
y = x[::-1]
print(y)
What will be the output?
A [1, 2, 3]
B [3, 2, 1]
C [3, 1, 2]
D Error
Correct Answer:  B. [3, 2, 1]
EXPLANATION

The slice notation [::-1] reverses the list. [1, 2, 3] reversed is [3, 2, 1].

Take Test
Advertisement
Q.86 Medium Basics & Syntax
What will be the output of: print(all([True, True, True]))?
A True
B False
C 1
D None
Correct Answer:  A. True
EXPLANATION

all() returns True if all elements are True. Since all three elements are True, the output is True.

Take Test
Q.87 Medium Basics & Syntax
Which of the following code snippets will execute without raising a NameError?
A print(undefined_variable)
B x = 5; print(x)
C print(y) where y is not defined
D print(2 + undefined)
Correct Answer:  B. x = 5; print(x)
EXPLANATION

Only option B defines x before using it. Other options reference undefined variables, causing NameError.

Take Test
Q.88 Medium Basics & Syntax
What will be the output of: x = '10'; y = int(x); print(y + 5)?
A '15'
B 15
C '105'
D Error
Correct Answer:  B. 15
EXPLANATION

int(x) converts the string '10' to integer 10. Adding 5 gives 15 (integer addition).

Take Test
Q.89 Medium Basics & Syntax
What will be the output of: print('a' * 3 + 'b' * 2)?
A aaabb
B aabbb
C ababab
D ab ab
Correct Answer:  A. aaabb
EXPLANATION

'a' * 3 produces 'aaa' and 'b' * 2 produces 'bb'. Concatenating gives 'aaabb'.

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

append() adds an element to the list. After adding 4, the list has 4 elements, so len(x) = 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