CBSE Class 11 Computer Science
Question 82 of 106
Python Fundamentals — Question 11
Back to all questions 11
Question Question 11
Find the errors in following code fragment :
c = input( "Enter your class" )
print ("Last year you were in class") c - 1There are two errors in this code fragment:
c - 1is outside the parenthesis of print function. It should be specified as one of the arguments of print function.- c is a string as input function returns a string. With
c - 1, we are trying to subtract a integer from a string which is an invalid operation in Python.
The corrected program is like this:
c = int(input( "Enter your class" ))
print ("Last year you were in class", c - 1)