Python Programming — Basics & Syntax
Python fundamentals to advanced for interviews
100 Questions 10 Topics Take Test
Advertisement
Showing 51–60 of 100 questions in Basics & Syntax
Q.51 Hard Basics & Syntax
Which of the following will raise a TypeError in Python?
A int('10')
B int(10.5)
C int('10.5')
D int(True)
Correct Answer:  C. int('10.5')
EXPLANATION

int('10.5') raises TypeError because '10.5' is a string representation of a float, not a valid integer string.

Take Test
Q.52 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.53 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.54 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.55 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.56 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
Q.57 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.58 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.59 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.60 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
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