QnA Conditional and Iterative Statements

Assignments – Chapter 5 Conditional and Iterative Statements

Short Answer Questions

Q -1 What are the types of statements available in Python?
Ans.: Python supports three types of statements:
    1. Empty Statement
    2. Simple Statement
    3. Compound Statement

Q – 2 What do you mean by pass statement in Python?

Ans.: The pass statement in python does nothing. It is an empty statement in python. In python, this statement has passed, python moves to the next statement in the flow of control.
Q – 3 What is a simple statement in python?
Ans.: A single statement is an executable line of code in the python program. For example, print(“Namaskaar!!!!!, Students how are you?”)
Q – 4 What is a compound statement in python?
Ans.: A compound statement is a set of statements in the on the program. It ends with the colon 👉 : sign. It has to parts as following:
    1. Header Line
    2. Statement Body 
Q – 5 In a program how the statements are executed?
Ans.: In a program, the statements can be executed sequentially, selectively, or iteratively. These statements are known as Sequence, Selection, and iteration. 
Q – 6 What is sequence construct? 
Ans.: The sequence construct means the statements are executed in a specific sequence. The python program starts from the top to bottom. 
Q – 7 What is selection construct?
Ans.: The selection construct means the choice of selection. The choice is based on the condition specified by the programmer. If the condition is true, an action can take place otherwise other actions can take place. 
Q – 8 What is the iteration? 
Q – 9 What are the stored conditions or named conditions in python?
Ans.:  The stored conditions or named conditions in python refers to a statement that stores a condition. These named conditions or stored conditions ads more flexibility in the program for reading and understanding the flow. For example,
silver_customer = bill_amt >= 20000 and bill_amt<=30000
gold_customer = bill_amt>=30000
if silver_customer:
Here silver_customer category is assigned to the customer whose bill amount is in the range between 20000 and 30000 as well as the gold_customer category is assigned to the customer whose bill amount is more than 30000 and given discounts accordingly.
Q – 10 What is a range function? Explain with example.

Application-based questions

Q – 1. Rewrite the following code fragment using if…elif..else statement:
color = input(“Enter the color name:”)
if (color==”red”):
   print(“Arun House”)
   print(“Aditya House”)
  print(“Ravi House”)
 print(“Bhaskar House”)
if(color!=”red” or color!=”blue” or color!=”yellow” or color!=”green”)
 print(“Not a valid color name!!!!”)
color = input(“Enter the color name:”)
if (color==”red”):
   print(“Arun House”)
   print(“Aditya House”)
  print(“Ravi House”)
 print(“Bhaskar House”)
 print(“Not a valid color name!!!!”)
Q – 2 What will the output of the following code fragment when the input is 7, 5, and 11?
if month>=6 and month<=9:
   print(“Term – I”)
elif month>=10 and month<=3:
   print(“Term – II”)
When the input is: 7 👉Term – I
When the input is: 5 👉Vacation
When the input is: 11 👉 Term – II

Comment Your Views

%d bloggers like this: