CBSE Class 11 Computer Science
Question 79 of 106
Python Fundamentals — Question 8
Back to all questions 8
Question Question 8
Find the errors in following code fragment
(a)
y = x + 5
print (x, Y)There are two errors in this code fragment:
- x is undefined in the statement
y = x + 5 - Y is undefined in the statement
print (x, Y). As Python is case-sensitive hence y and Y will be treated as two different variables.
(b)
print (x = y = 5)Python doesn't allow assignment of variables while they are getting printed.
(c)
a = input("value")
b = a/2
print (a, b)The input( ) function always returns a value of String type so variable a is a string. This statement b = a/2 is trying to divide a string with an integer which is invalid operation in Python.