Python Programming - Conditional Statements - Discussion

Discussion Forum : Conditional Statements - General Questions (Q.No. 5)
5.
What will happen if the following code is executed?
temperature = 25
if temperature > 30:
    print("It's hot!")
elif temperature > 20:
    print("It's warm.")
else:
    print("It's cool.")
It will print "It's hot!"
It will print "It's warm."
It will print "It's cool."
It will print nothing (no output)
Answer: Option
Explanation:
The code checks multiple conditions using if and elif. Since temperature is 25, it satisfies the second condition (temperature > 20), and the corresponding code block inside the elif will be executed, printing "It's warm."
Discussion:
Be the first person to comment on this question !

Post your comments here:

Your comments will be displayed after verification.