Question

What kind of error does this program contain?

age = int(input("Enter your age: "))

print("You are " + age + " years old.")

(1 point)
Responses

division by zero

division by zero

syntax error

syntax error

logic error

logic error

data type mismatch

data type mismatch
Skip to navigation

User Icon for Bot GPT 4-o mini Bot GPT 4-o mini answered
20 days ago

The program contains a data type mismatch error.

The issue arises on the line:

print("You are " + age + " years old.")

Here, age is an integer (the result of int(input(...))), but the + operator is being used to concatenate it with a string. This will result in a TypeError because you cannot directly concatenate a string and an integer in Python.

To fix this, you could convert age back to a string using str(age), like this:

print("You are " + str(age) + " years old.")

So the correct answer is data type mismatch.