Module II – Python: Decision Control Statements,
Functions and Modules
2 Mark Questions and Answers
1. What are decision control statements in Python?
Decision control statements are used to control the flow of execution based on certain
conditions using if, elif, and else statements.
2. What is a loop in Python?
A loop is used to execute a block of code repeatedly until a certain condition is met.
3. What is the purpose of the break statement?
The break statement is used to terminate the loop prematurely when a specific condition is
met.
4. What is a function in Python?
A function is a reusable block of code that performs a specific task when called.
5. What is a lambda function?
A lambda function is an anonymous, single-line function defined using the 'lambda'
keyword.
6. What is recursion?
Recursion is a programming technique where a function calls itself to solve a problem.
7. What are modules in Python?
Modules are files containing Python code (functions, variables, classes) that can be
imported and reused in other programs.
8. What is the difference between pass and continue?
‘pass’ does nothing and acts as a placeholder, while ‘continue’ skips the rest of the loop
body and moves to the next iteration.
9. What is a package in Python?
A package is a collection of Python modules organized in directories with an __init__.py
file.
10. What is variable scope?
Scope defines the region where a variable is accessible in a program (local, global, or
nonlocal).
10 Mark Questions and Answers
1. Explain selection and conditional branching statements in Python with examples.
Selection and conditional branching in Python are achieved using if, elif, and else
statements. They help execute specific blocks of code based on conditions. Example: if x
> 0: print("Positive") elif x == 0: print("Zero") else: print("Negative") These allow
decision-making and control program flow.
2. Explain iterative statements and different types of loops in Python with examples.
Iterative statements are used to execute a block of code repeatedly. Types of loops: 1. for
loop – Iterates over a sequence (list, tuple, range). 2. while loop – Repeats while a
condition is true. Example: for i in range(5): print(i) while x < 10: x += 1 Loops reduce code
repetition and simplify tasks.
3. Describe break, continue, and pass statements with suitable examples.
break: Exits from the loop completely. continue: Skips the current iteration and moves to
the next. pass: Acts as a null statement (used as a placeholder). Example: for i in
range(5): if i == 2: continue print(i) These statements provide better control within loops.
4. Explain functions in Python and their types with examples.
Functions help organize code into reusable blocks. Types of Functions: 1. Built-in
functions (e.g., len(), sum()) 2. User-defined functions 3. Lambda functions 4. Recursive
functions Example: def add(a, b): return a + b Lambda: add = lambda a, b: a + b Functions
improve code modularity and readability.
5. Explain modules and different methods of importing them with examples.
Modules are Python files containing reusable code. Import methods: 1. import
module_name 2. from module_name import function_name 3. import module_name as
alias Example: import math print([Link](16)) Modules promote reusability and better
organization of code.