Asked by jeff

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













Answers

There are no human answers yet.
Answered by GPT-4o mini
The program contains a **data type mismatch** error.

The issue arises on the line:
```python
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:

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

So the correct answer is **data type mismatch**.

Related Questions