← Back to Subject
Python Programming • MCQ • Control Flow Statements, Function and Loops
Most Important 30 Objective Question - Control Flow Statements, Function and Loops
Q1. Which statement is used for decision making in Python?

A) loop
B) if
C) print
D) input

Answer: B) if

Explanation:
The if statement is used to test a condition and make decisions based on True or False.

Q2. Which keyword is used with if when the condition is false?

A) else
B) for
C) while
D) break

Answer: A) else

Explanation:
else executes when the condition in if becomes false.

Q3. Which keyword is used for multiple conditions?

A) elseif
B) elif
C) else if
D) ifelse

Answer: B) elif

Explanation:
Python uses elif for checking multiple conditions.

Q4. What is a nested if statement?

A) if inside another if
B) if inside loop
C) loop inside if
D) print inside if

Answer: A) if inside another if

Explanation:
When one if statement is placed inside another if, it is called nested if.

Q5. Which loop is used when the number of iterations is known?

A) while
B) for
C) do while
D) nested loop

Answer: B) for

Explanation:
for loop is commonly used when the number of repetitions is known.

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

A) for
B) while
C) if
D) switch

Answer: B) while

Explanation:
while loop runs until the condition becomes false.

Q7. Which keyword is used to stop a loop completely?

A) continue
B) pass
C) break
D) stop

Answer: C) break

Explanation:
break immediately terminates the loop.

Q8. Which keyword skips the current iteration?

A) continue
B) break
C) stop
D) next

Answer: A) continue

Explanation:
continue skips the current iteration and moves to the next one.

Q9. Which function is used to define a function?

A) function
B) define
C) def
D) fun

Answer: C) def

Explanation:
Functions in Python are created using the def keyword.

Q10. Which keyword is used to return a value from a function?

A) print
B) break
C) return
D) continue

Answer: C) return

Explanation:
return sends a value back from the function to the caller.

Q11. A function without return statement returns:

A) 0
B) False
C) None
D) Error

Answer: C) None

Explanation:
If no return is written, Python automatically returns None.

Q12. Which of the following is a built-in function?

A) add()
B) len()
C) sumall()
D) total()

Answer: B) len()

Explanation:
len() is a built-in function used to find the length of an object.

Q13. Which function gives the absolute value?

A) abs()
B) sum()
C) max()
D) min()

Answer: A) abs()

Explanation:
abs() returns the positive value of a number.

Example: abs(-5) = 5

Q14. Which module is used for mathematical operations?

A) random
B) math
C) os
D) csv

Answer: B) math

Explanation:
The math module provides mathematical functions like sqrt(), factorial(), etc.

Q15. Which function is used to find square root?

A) sqrt()
B) square()
C) root()
D) pow() only

Answer: A) sqrt()

Explanation:
sqrt() is used from the math module to calculate square root.

Q16. What is the output of range(5)?

A) 1 to 5
B) 0 to 4
C) 0 to 5
D) 1 to 4

Answer: B) 0 to 4

Explanation:
range(5) starts from 0 by default and stops before 5.

Q17. Which function is used to find maximum value?

A) max()
B) high()
C) maximum()
D) top()

Answer: A) max()

Explanation:
max() returns the largest value.

Q18. Which function is used to find minimum value?

A) min()
B) low()
C) minimum()
D) bottom()

Answer: A) min()

Explanation:
min() returns the smallest value.

Q19. What is scope of a variable?

A) Value of variable
B) Area where variable can be used
C) Type of variable
D) Function name

Answer: B) Area where variable can be used

Explanation:
Scope defines where the variable is accessible.

Q20. Variables created inside a function are called:

A) Global variables
B) Local variables
C) Static variables
D) Constant variables

Answer: B) Local variables

Explanation:
Variables inside a function are local and work only inside that function.

Q21. Variables created outside all functions are called:

A) Local
B) Global
C) Nested
D) Hidden

Answer: B) Global

Explanation:
Global variables can be accessed throughout the program.

Q22. What are default parameters?

A) Fixed values
B) Parameters with predefined values
C) Hidden values
D) Global values

Answer: B) Parameters with predefined values

Explanation:
If the user does not pass a value, the default value is used.

Q23. Example of default parameter:

A) def add(a=10):
B) def add(a+10):
C) def add(=10):
D) def add(a==10):

Answer: A) def add(a=10):

Explanation:
This is correct syntax for default arguments.

Q24. Which loop can run forever if condition never becomes false?

A) for
B) while
C) if
D) else

Answer: B) while

Explanation:
This is called an infinite loop.

Q25. Which symbol is used after if condition?

A) ;
B) :
C) ,
D) .

Answer: B) :

Explanation:
Python uses colon : after if, for, while, and function definitions.

Q26. What is the output of bool(0)?

A) True
B) False
C) Error
D) None

Answer: B) False

Explanation:
Zero is treated as False in Python.

Q27. Which statement does nothing?

A) break
B) continue
C) pass
D) return

Answer: C) pass

Explanation:
pass is a null statement used when no action is required.

Q28. Which function adds all values?

A) add()
B) sum()
C) total()
D) plus()

Answer: B) sum()

Explanation:
sum() adds all numeric values of a list or iterable.

Q29. Which loop is best for traversing a list?

A) if
B) while
C) for
D) else

Answer: C) for

Explanation:
for loop is commonly used to iterate through lists.

Q30. Which statement is correct?

A) Python supports functions
B) Python does not support loops
C) Python has no conditions
D) Python has no return statement

Answer: A) Python supports functions

Explanation:
Python supports functions, loops, conditions, modules, and much more.
Google AdSense Ad Placement Here 📢