Python Programming
Python fundamentals to advanced for interviews
119 Questions 10 Topics Take Test
Advertisement
Showing 71–80 of 119 questions
Q.71 Medium Basics & Syntax
What will be the output of: x = 10; y = 20; x, y = y, x; print(x, y)
A 10 20
B 20 10
C Error
D 20 20
Correct Answer:  B. 20 10
EXPLANATION

Python tuple unpacking allows simultaneous assignment, effectively swapping x and y.

Take Test
Q.72 Medium Basics & Syntax
Consider: s = 'Python'; print(s[2:5]). What will be the output?
A tho
B yth
C Pyt
D hon
Correct Answer:  A. tho
EXPLANATION

String slicing s[2:5] includes indices 2, 3, 4. 'Python'[2:5] = 'tho'.

Take Test
Q.73 Medium Basics & Syntax
What is the output of: for i in range(3): print(i, end=' ')
A 1 2 3
B 0 1 2
C 0 1 2 3
D 3 2 1
Correct Answer:  B. 0 1 2
EXPLANATION

range(3) generates 0, 1, 2. The end=' ' parameter prevents newline after each print.

Take Test
Q.74 Medium Basics & Syntax
Which operator in Python performs integer division?
A /
B //
C %
D **
Correct Answer:  B. //
EXPLANATION

The // operator performs floor division, returning the integer quotient.

Take Test
Q.75 Medium Basics & Syntax
What will be the output of: print(bool(0), bool(''), bool([]))
A True True True
B False False False
C True False True
D Error
Correct Answer:  B. False False False
EXPLANATION

0, empty string '', and empty list [] are all falsy values in Python, so bool() returns False for each.

Take Test
Advertisement
Q.76 Medium Basics & Syntax
Consider the code: x = [10, 20, 30]; y = x; y[0] = 99; print(x[0]). What is the output?
A 10
B 99
C Error
D 20
Correct Answer:  B. 99
EXPLANATION

y = x creates a reference to the same list, not a copy. Modifying y also modifies x.

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

extend() adds each element of the iterable to the list, resulting in [1, 2, 3, 4, 5].

Take Test
Q.78 Medium Basics & Syntax
What is the output of: x = '25'; y = int(x); print(y + 5)
A '255'
B 30
C Error
D '30'
Correct Answer:  B. 30
EXPLANATION

int('25') converts the string to integer 25, then 25 + 5 = 30.

Take Test
Q.79 Easy Basics & Syntax
What will be the output of: print(type(3.14))
A
B
C
D
Correct Answer:  B.
EXPLANATION

3.14 is a floating-point number, so type() returns <class 'float'>.

Take Test
Q.80 Easy Basics & Syntax
What does len() function return when applied to a string?
A The ASCII value of first character
B The number of characters in the string
C The memory size of the string
D The index of last character
Correct Answer:  B. The number of characters in the string
EXPLANATION

The len() function returns the number of characters (length) in a string.

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