VERY SHORT ANSWER QUESTIONS:
1. What is a statement?
Ans: Instructions that a Python interpreter can execute are called statements.
2. What is a compound statement?
Ans: A compound statement is a grouping of statements executed as a unit. The group of
statements is also called Block.
3. What is a conditional statement?
Ans: Conditionals are fundamental programming constructs in Python which help us to control
the flow of our program based on specified conditions.
4. What is an if statement?
Ans: The ‘if ’ statement helps in selecting one alternative out of the two. The execution of ‘if’
statement starts with the evaluation of condition.
5. Draw a flow chart for if statement.
Ans: if expression:
Statement(s);
6. What is the function of if else construct?
Ans: The if….else construct in Python is used for decision-making in our code. It allows us to
execute certain blocks of code based on whether a condition is true or False.
7. What is the use of if elif construct?
Ans: The if….elif construct in Python is used to check multiple conditions in a sequence and
execute different locks of code based on which condition is true.
8. What is iteration?
Ans: Iterative statements are used to execute a part of the program repeatedly as long as a given
condition is True.
9. What is the difference between for and while loop?
Ans: The main difference in While loop and for loop is that while loop is used when we are not
certain of the number of times the loop requires execution, whereas, for loop is used when the
number of iterations is known.
10. What is the use of else statement with the for loop?
Ans: Python allows the else keyword with for loop. A for loop can have an optional else block as
well. The else part is executed if the items in the sequence used in for loop exhausts.
11. What is the use of else statement with while loop?
Ans: We can have an else clause with the while loop. The else statement is optional. It executes
only after the loop finished execution.
12. What is the use of break statement?
Ans: The break statement is used to exit a for or a while loop. The purpose of this statement is
to end the execution of the loop immediately and the program control goes to the statement of
the loop.
Syntax: while(expression1):
Statement_1
Statement_2
………
If expression2:
Break
For variable_name in sequence:
Statement_1
Statement_2
If expression3:
break
13. What is the use of continue statement?
Ans: The continue statement is used in a while or for loop to take the control of the top of the
loop without executing the rest statements inside the loop.
Syntax:
14. What is the use of pass statement in a program?
Ans: The pass statement does nothing. We can use the pass statement when we create a
method that we do not want to implement yet but later on.
Syntax: pass
15. What is an infinite loop?
Ans: A loop becomes infinite loop if a condition remains always true. Since the condition is
always true, the loop never stops. Such a loop is called an infinite loop.
SHORT ANSWER TYPE QUESTIONS:
1. Write the uses of if statement.
Ans: The ‘if’ statement helps in selecting one alternative out of the two. The execution of ‘if’
statement starts with the evaluation of condition. The ‘if’ statement helps the programmer to test
for the condition. This is a powerful decision-making statement.
2. What is the difference between break and continue statements.
Ans: Break statement: The break statement is used to exit a for or a while loop. The purpose of this
statement is to end the execution of the loop immediately and the program control goes to the
statement after the last statement of the loop.
Continue statement: The continue statement is used in a while or for loop to take the
control to the top of the loop without executing the rest statements inside the loop.
LONG ANSWER TYPE QUESTIONS:
1. What is if else ladder? Explain with the help of an example.
Ans: The if-else ladder in Python is a series of conditional statements that allow us to
execute different blocks of code based on multiple conditions. It is useful when we have
more than two possible outcomes.
Syntax:
If condition1:
Statements(s)
Elif condition2:
Statements(s)
Elif condition3:
Statement(s)
Else:
Statement(s)
Example:
Print(“Enter marks: ”)
Mark= int(input())
If mark>=80:
Print(“Grade: A”)
Elif mark>=65:
Print(“Grade: B”)
Elif mark>=50:
Print(“Grade: C”)
Else:
Print(“Grade: D”)