A developer runs the script and enters 'Alice' and '25'. What does it print?
Exhibit
Refer to the exhibit.
name = input('Enter name: ')
age = input('Enter age: ')
print(name + ' is ' + age + ' years old.')
If the user enters 'Alice' and '25', what is the output?Trap 1: Alice is 25.0 years old.
Incorrect: This would occur if the age were converted to a float (e.g., float(input())), but input() returns a string, so no decimal point appears.
Trap 2: Alice is Alice is 25 years old.
Incorrect: This shows the name repeated and extra spaces, which would not happen with print(name, 'is', age, 'years old.') because commas separate arguments and add single spaces.
Trap 3: Alice is 25 years old
Incorrect: Although it states 'with age as integer', the output would still be 'Alice is 25 years old.' without any integer indication; the phrase in parentheses is not printed.
- A
Alice is 25.0 years old.
Why wrong: Incorrect: This would occur if the age were converted to a float (e.g., float(input())), but input() returns a string, so no decimal point appears.
- B
Alice is Alice is 25 years old.
Why wrong: Incorrect: This shows the name repeated and extra spaces, which would not happen with print(name, 'is', age, 'years old.') because commas separate arguments and add single spaces.
- C
Alice is 25 years old. (with age as integer)
Why wrong: Incorrect: Although it states 'with age as integer', the output would still be 'Alice is 25 years old.' without any integer indication; the phrase in parentheses is not printed.
- D
Alice is 25 years old.
Correct: As explained, the output is exactly 'Alice is 25 years old.' because the age string is printed as-is with spaces.