CBSE Class 11 Computer Science Question 91 of 106

Python Fundamentals — Question 20

Back to all questions
20
Question

Question 20

Correct the following program so that it displays 33 when 30 is input.

val = input("Enter a value")
nval = val + 30
print(nval)
Answer

Below is the corrected program:

val = int(input("Enter a value"))    #used int() to convert input value into integer 
nval = val + 3    #changed 30 to 3
print(nval)