iGET

Python Programming - MCQ Practice Questions

Core Python MCQs — syntax, data types, OOP, libraries for placements & IT exams.

189 questions | 100% Free

Q.1Medium

What will be the output of the following code? def greet(name, msg='Hello'): return f'{msg}, {name}!' print(greet('Alice')) print(greet('Bob', 'Hi'))

Q.2Medium

What will be the output of the following code? def func(*args, **kwargs): print(len(args), len(kwargs)) func(1, 2, 3, a=4, b=5)

Q.3Medium

Which of the following statements about lambda functions in Python is CORRECT?

Q.4Medium

What will be the output of the following code? def outer(): x = 10 def inner(): nonlocal x x += 5 inner() return x print(outer())

Q.5Medium

What is the purpose of the __init__.py file in a Python package directory?

Q.6Medium

What will be the output of the following code? def add(a, b): return a + b result = add print(result(3, 4))

Q.7Medium

Which of the following correctly imports only the sqrt function from the math module?

Q.8Medium

What will be the output of the following code? def counter(): count = 0 def increment(): nonlocal count count += 1 return count return increment c = counter() print(c()) print(c()) print(c())

Q.9Medium

What will be the output of the following code? import math as m print(m.floor(4.7)) print(m.ceil(4.2))

Q.10Medium

What will be the output of the following code? def apply(func, value): return func(value) result = apply(lambda x: x ** 2, 5) print(result)