CBSE Class 11 Computer Science
Question 74 of 106
Python Fundamentals — Question 3
Back to all questions 3
Question Question 3
Find out the error(s) in following code fragments:
(i)
temperature = 90
print temperatureThe call to print function is missing parenthesis. The correct way to call print function is this:print(temperature)
(ii)
a = 30
b=a+b
print (a And b)There are two errors in this code fragment:
- In the statement
b=a+bvariable b is undefined. - In the statement
print (a And b), And should be written as and.
(iii)
a, b, c = 2, 8, 9
print (a, b, c)
c, b, a = a, b, c
print (a ; b ; c)In the statement print (a ; b ; c) use of semicolon will give error. In place of semicolon, we must use comma like this print (a, b, c)
(iv)
X = 24
4 = XThe statement 4 = X is incorrect as 4 cannot be a Lvalue. It is a Rvalue.
(v)
print("X ="X)There are two errors in this code fragment:
- Variable X is undefined
- "X =" and X should be separated by a comma like this
print("X =", X)
(vi)
else = 21 - 5else is a keyword in Python so it can't be used as a variable name.