Chapter 9-LEARNING CONDITIONAL STATEMENTS-GRADE 7
Chapter 9-LEARNING CONDITIONAL STATEMENTS-GRADE 7
2.b
3.b
4.a
5.a
6.b
7.a
8.a
B.True or false
Ans:Syntax:
If condition:
Set of statement(s)
2.Explain the working of if-else statement
Ans:An if-else statement is a control structure in programming that executes different blocks of
code based on whether a condition is true or false.
How it works
● The if-else statement evaluates a condition
● If the condition is true, the code in the if block is executed
● If the condition is false, the code in the else block is executed
Ans:The if-elif-else statement is a conditional statement in Python that lets you execute different
code based on a condition. It's useful for handling multiple conditions and complex scenarios.
Ans:Yes
5.In case the if condition evaluates to false,then which block statements will work?
Ans:Else block
num1=int(input('enter number1'))
num2=int(input('enter number2'))
num3=int(input('enter number3'))
if(num1>num2) and (num1>num3):
print(num1,"is greater")
elif (num2>num1) and (num2>num3):
print(num2, "is greater")
else :
print(num3, "is greater")
4.Write a program to read temperature in centigrade and display a suitable message according to
temperature.
Temp=int(input("Enter the Temperature"))
if Temp<0:
print("freezing weather")
elif (Temp>=0 and Temp<10):
print("very cold weather")
elif (Temp>=10 and Temp<20):
print("cold weather")
elif (Temp>=20 and Temp<30):
print("Normal weather")
elif (Temp>=30 and Temp<40):
print("hot weather")
elif (Temp>=40):
print("very hot weather")