CBSE Class 11 Computer Science Question 73 of 98

Python Programming Fundamentals — Question 35

Back to all questions
35
Question

Question 23(b)

Find errors in the following code fragment.

Name = "Prateek"
Age = 26
print("your name & age are", Name + Age)
Answer

The error in the above code is in the print statement. We cannot concatenate a string (Name) and an integer (Age) directly using the '+' operator. The corrected code is:

Name = "Prateek"
Age = 26
print("Your name & age are", Name + str(Age))