0% found this document useful (0 votes)
54 views11 pages

MCQ Module 1

The document contains a comprehensive quiz on Python programming, divided into three difficulty levels: Easy, Medium, and Difficult. It covers various topics including Python basics, flow control, and functions, with multiple-choice questions and correct answers indicated. Each section tests knowledge on syntax, functions, and programming concepts relevant to Python.

Uploaded by

pavithra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
54 views11 pages

MCQ Module 1

The document contains a comprehensive quiz on Python programming, divided into three difficulty levels: Easy, Medium, and Difficult. It covers various topics including Python basics, flow control, and functions, with multiple-choice questions and correct answers indicated. Each section tests knowledge on syntax, functions, and programming concepts relevant to Python.

Uploaded by

pavithra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 11

MODULE 1:

Python Basics

Easy (10 Questions)

1. What is the primary use of Python?

A) Web Browsing

B) Automating Tasks ✅

C) Playing Music

D) Designing Graphics

2. What symbol is used for comments in Python?

A) //

B) --

C) # ✅

D) /* */

3. What will print(3 + 4 * 2) output?

A) 14 ✅

B) 11

C) 10

D) 8

4. What function is used to display output in Python?

A) echo()

B) display()

C) print() ✅

D) show()

5. How do you declare a variable in Python?

A) int x = 5;

B) x := 5

C) x = 5 ✅

D) var x = 5

6. What will type(10.5) return?

A) int

B) str
C) float ✅

D) double

7. What operator is used for exponentiation in Python?

A) ^

B) ** ✅

C) //

D) %

8. Which function is used to take user input?

A) read()

B) scan()

C) input() ✅

D) get()

9. What will print("Hello" + "World") output?

A) Hello+World

B) Hello World

C) HelloWorld ✅

D) Hello, World

10. What will print(10 // 3) return?

A) 3.33

B) 3 ✅

C) 4

D) Error

Medium (6 Questions)

11. What does len("Python") return?

A) 5

B) 6 ✅

C) 7

D) Error

12. What does print("Hello\nWorld") output?

A) Hello World

B) Hello\nWorld
C)

Hello

World

``` ✅

D) HelloWorld

13. What happens if you divide by zero in Python?

A) Returns 0

B) Returns None

C) Raises an error ✅

D) Returns Infinity

14. What will print("3" * 3) output?

A) 9

B) 333 ✅

C) Error

D) 3333

15. How can you check the type of a variable?

A) typeof()

B) isType()

C) type() ✅

D) getType()

16. What is the default data type of user input?

A) int

B) float

C) str ✅

D) bool

Difficult (4 Questions)

17. What is the output of bool("")?

A) True

B) False ✅

C) None

D) Error
18. What is the result of 2 and 3?

A) True

B) False

C) 2

D) 3 ✅

19. What will print(5 > 4 > 3) output?

A) True ✅

B) False

C) Error

D) None

20. What does round(2.5) return in Python 3?

A) 2

B) 3 ✅

C) 2.5

D) Error

Flow Control

Easy (10 Questions)

1. Which keyword is used to create an if statement in Python?

A) if ✅

B) when

C) case

D) switch

2. What is the output of print(5 == 5)?

A) True ✅

B) False

C) 5

D) Error

3. Which operator represents logical "AND" in Python?

A) &&

B) ||
C) and ✅

D) &

4. What does an else statement do?

A) Executes when if is True

B) Executes when if is False ✅

C) Repeats a loop

D) Declares a function

5. How many times will this loop execute?

for i in range(3):

print(i)

A) 2

B) 3 ✅

C) 4

D) Infinite

6. Which loop is used when the number of iterations is unknown?

A) for

B) while ✅

C) foreach

D) do while

7. What keyword is used to exit a loop?

A) return

B) stop

C) break ✅

D) continue

8. What will print(True and False) return?

A) True

B) False ✅

C) None

D) Error

9. What is the output of print(not False)?

A) True ✅
B) False

C) None

D) Error

10. What will print(10 != 10) output?

A) True

B) False ✅

C) 10

D) None

Medium (6 Questions)

11. What will print(5 or 0) return?

A) 0

B) 5 ✅

C) True

D) None

12. Which statement continues to the next iteration of a loop?

A) skip

B) jump

C) continue ✅

D) break

13. How many times does this loop execute?

count = 1

while count < 4:

count += 1

A) 3 ✅

B) 4

C) Infinite

D) 1

14. What is the output of print(2 in [1, 2, 3])?

A) True ✅

B) False

C) None
D) Error

15. Which loop structure executes at least once?

A) for

B) while

C) do-while ✅

D) foreach

16. What does range(1, 5, 2) generate?

A) [1, 2, 3, 4]

B) [1, 3] ✅

C) [1, 5]

D) [2, 4]

Difficult (4 Questions)

17. What is the output of print(bool([]))?

A) True

B) False ✅

C) None

D) Error

18. What will print(3 > 2 > 1) return?

A) True ✅

B) False

C) None

D) Error

19. What happens if a loop condition never becomes false?

A) The loop executes once

B) The loop runs infinitely ✅

C) The program crashes immediately

D) The loop stops after 10 iterations

20. What is the correct syntax for a ternary conditional statement?

A) if a: b else: c

B) b if a else c ✅

C) a ? b : c
D) b unless a c

Functions

Easy (10 Questions)

1. What keyword is used to define a function in Python?

A) function

B) define

C) def ✅

D) fn

2. How do you call a function named hello?

A) hello() ✅

B) call hello

C) run hello()

D) invoke hello

3. What will print(abs(-5)) return?

A) 5 ✅

B) -5

C) 0

D) Error

4. Which statement exits a function?

A) stop

B) break

C) return ✅

D) exit

5. What is the output of print(max(2, 3, 5))?

A) 2

B) 3

C) 5 ✅

D) Error

6. What is the default return type of a function that has no return statement?

A) None ✅
B) 0

C) False

D) Error

7. Which function gives the length of a string?

A) size()

B) count()

C) length()

D) len() ✅

8. What is the output of print(str(10))?

A) "10" ✅

B) 10

C) Error

D) None

9. What will round(4.7) return?

A) 4

B) 5 ✅

C) 4.5

D) None

10. How do you specify a default parameter in a function?

A) def fun(a=5): ✅

B) def fun(a: 5):

C) def fun(a 5):

D) def fun(5=a):

Medium (6 Questions)

11. What does lambda x: x + 2 define?

A) A variable

B) A loop

C) An anonymous function ✅

D) A tuple

12. What is *args used for?

A) To pass unlimited arguments ✅


B) To pass dictionaries

C) To define return types

D) To specify conditions

13. What will print(sum([1,2,3])) return?

A) Error

B) 6 ✅

C) [1,2,3]

D) 123

14. What does return do in a function?

A) Ends the function ✅

B) Repeats execution

C) Calls another function

D) Creates a variable

15. What is the output of print(bool(0))?

A) True

B) False ✅

C) None

D) Error

16. What does global x do inside a function?

A) Makes x a global variable ✅

B) Deletes x

C) Returns x

D) Creates a new variable

Difficult Questions

17. What will be the output of the following code?

def func(a, b=[]):

b.append(a)

return b

print(func(1))

print(func(2))

print(func(3, []))
print(func(4))

A) [1] [2] [3] [4]

B) [1] [1, 2] [3] [1, 2, 4] ✅

C) [1] [2] [3] [4] []

D) Error

18. What happens when a function calls itself recursively without a base condition?

A) It runs indefinitely

B) It results in a syntax error

C) It raises a RecursionError after a certain limit ✅

D) It executes only once

19. What will be the output of the following function?

def mystery(x, y=[]):

y.append(x)

return y

a = mystery(1)

b = mystery(2, [])

c = mystery(3)

A) a = [1], b = [2], c = [3]

B) a = [1, 3], b = [2], c = [1, 3] ✅

C) a = [1], b = [2], c = [1]

D) Error

20. What does the following function return?

def test(x, *args, y=10, **kwargs):

return x, args, y, kwargs

print(test(1, 2, 3, a=4, b=5))

A) (1, (2, 3), 10, {'a': 4, 'b': 5}) ✅

B) (1, 2, 3, 10, {'a': 4, 'b': 5})

C) (1, (2, 3), {'a': 4, 'b': 5}, 10)

D) Error

You might also like