CBSE Class 11 Informatics Practices
Question 31 of 75
Conditional and Looping Constructs — Question 3
Back to all questionscode = input("Enter season code : ")
if code=w: #Error 1
print "winter season" #Error 2
elif code==r: #Error 3
PRINT "rainy season" #Error 4
else:
Print "summer season" # Error 5Error 1 — The assignment operator '=' is used instead of equality operator '==' in the if statement and the string 'w' should be enclosed in quotes.
Error 2 — Parentheses around the print statement are missing.
Error 3 — String 'r' should be enclosed in quotes.
Error 4 — The print statement should be in lowercase letters and there should be parentheses around the print statement.
Error 5 — The print statement should be in lowercase letters and there should be parentheses around the print statement.
The corrected code is :
code = input("Enter season code: ")
if code == "w":
print("winter season")
elif code == "r":
print("rainy season")
else:
print("summer season")