0% found this document useful (0 votes)
111 views

Ch – 7 Control Structures in Python

Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
111 views

Ch – 7 Control Structures in Python

Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Ch – 7 Control Structures in Python

ASSESS YOURSELF
1. Tick ()the correct option –
a. Which of the following is a selective structure?
(i) Identifiers, Operators (ii) if-else 
(iii) for, while (iv) None of these
b. Which of the following is a decision-making statement?
(i) if  (ii) for
(iii) while (iv) do while
c. Which statement is used in loops to terminate the loop?
(i) if (ii) Continue
(iii) break  (iv) All of these
d. Which of the following statements is used to repeat a block of code?
(i) for  (ii) Range
(iii) if-else (iv) Both (i) & (ii)

2. Fill in the blanks –


a. A control statement is a programming construct which affects the flow of the execution of a
program.
b. The statement which are executed one after the other without any jumps are called sequential
statements.
c. When programmers are required to execute a particular set of statements depending upon a
particular test condition, a conditional statement is required.
d. The continue statement causes the program to skip the rest of the statement of the current
block and to move to next iteration of the loop.

3. Answer in one or two words –


a. What is a set of instructions of a computer program known as?
Ans. Software
b. Name any one iterative statement.
Ans. for/while
c. Which function is used to generate a list of numbers from a starting number up to the
number just before the ending number?
Ans. Range
d. Under which condition does a looping statement enable the repetition of task under its
scope?
Ans. TRUE

4. Think and Answer –


a. What do you understand by control structure?
Ans. A control structure is a programming language construct which affects the flow of the
execution of a program.
b. What is the if-elif-else statement used for? Write its syntax.
Ans. First, it checks and evaluates the first condition. If it is true, it will execute the respective
statement(s), but if the condition is false, it goes to the elif statement and evaluated that
conditions. Finally, if none of the conditions evaluates to true it executes the else block.
The syntax of if-elif-else statement is as
follows: if (conditional expression):
statement(s)
elif (conditional expression):
statement(s)
elif (conditional
expression):
statement(s)
else:
statement(s)
c. Write the syntax of the following -
Ans. (i) While loop - while(loop - condition):
statement(s)
(ii) Nested if statements - if (conditional expression):
statement(s)
if (conditional
expression2):
statement(s)
elif (conditional expression3):
statement(s)
else:
statement(s)
else:
statement(s)
d. What are jump statements? Define the jump statements used in Python.
Ans. These statements are used to jump out of the loop iterations even if the condition has not
become false. They alter the flow of control unconditionally. The jump statements defined in
Python are break and continue.
THE break STATEMENT
The break statement is used in the for and while loops to terminate the loop and completely
transfer the control from the loop to the next statement after the body of the loop. It is mostly
used when we need to exit from a loop at times.
THE continue STATEMENT
The continue statement causes the program to skip the rest of the statement of the current
block and move to the next iteration of the loop. It immediately transfers control to the
evaluation of the test expression of the loop for the next iteration of the loop.
5. Application based questions –
a. Shweta was writing a program in which she wanted to execute a particular set of
statements depending upon a particular test condition. Which type of statements can she use
for this? Ans. Selection statements
b. Swara wants to repeat a block of statements for a given number of times, until the control
condition is false. Which type of construct can she use for this? Write its syntax.
Ans. Iterative Statements
Syntax: for <variable> in <sequence>:
statement(s)
c. Manvi wants to write a statement which will cause the program to skip the rest of the
statement of the current block and to move to the next iteration of the loop. Which
statement should she use for this?
Ans. Continue statement

6. Write the output of the following codes in Python –


a. l=29
m=29
if m>l:
print(“m is greater than
l”) elif l==m:
print (“l and m are equal”)
Ans. l and m are equal
b. sum1=0
n=int(input(“Please enter number: ”))
for i in range(1, n+1, 1):
sum1+=i
print(“Sum is: “,sum1)
Ans. Please enter number:
5 Sum is: 15
c. num=24894
count=0
while num !=0:
num//=10
count+=1
print(“Total digits are: “,count)
Ans. Total digits are: 5

You might also like