Courseiva

PCEP Computer Programming and Python Fundamentals Practice Question

A programmer writes the following code to convert a user's input to a number and add 5:

age = input('Enter age: ') new_age = int(age) + 5

print(new_age)

If the user enters 'twenty', what happens?

⚠ Common exam trap

Watch out — candidates often confuse runtime ValueError with compile-time SyntaxError, or assuming int() understands English number words.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

✓

A ValueError is raised because int() cannot convert the string 'twenty' to an integer.

The int() function raises a ValueError when given a string that is not a valid integer literal. Since 'twenty' is not numeric, the conversion fails at runtime. The code itself is syntactically valid, so it is not a SyntaxError. The program will crash with a traceback unless the error is caught.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ✗

    The program prints 25 because int('twenty') returns 20.

    Why it's wrong here

    int('twenty') does not return 20; it raises a ValueError because 'twenty' is not a numeric string. Python does not interpret English number words. The int() function only accepts strings that look like integer literals, such as '20' or '-5'. So this option is incorrect.

  • ✗

    The program prints 'twenty5' because int() converts the string to 20 and concatenates 5.

    Why it's wrong here

    int() does not convert 'twenty' to 20; it raises an exception. Even if it did, the + operator with an int and a string would raise TypeError, not concatenate, because you cannot add int and str. So this behavior is not correct. The actual result is a ValueError.

  • ✓

    A ValueError is raised because int() cannot convert the string 'twenty' to an integer.

    Why this is correct

    The int() function attempts to parse the string argument as an integer. The string 'twenty' does not represent a valid integer literal, so Python raises a ValueError. This is a runtime error, not a syntax error, because the code is syntactically correct. The program will terminate with a traceback unless the exception is handled.

  • ✗

    A SyntaxError occurs because 'twenty' is not a number.

    Why it's wrong here

    A SyntaxError is raised during parsing when code violates Python syntax, before execution. Here the code is syntactically valid; the error occurs at runtime when int() is called with an invalid string. So it is not a SyntaxError. The distinction is important for debugging.

Visual reference

Client Server SYN (seq=100) SYN-ACK (seq=200, ack=101) ACK (ack=201) Connection established — data transfer begins

About these practice questions

One of 482 original PCEP practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written and reviewed by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

Last reviewed September 2026 · checked against the official Python Institute exam blueprint

This PCEP practice question is part of Courseiva's free Python Institute certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the PCEP exam.