PCEP Practice Question: Data Types, Variables, Basic I/O and Operators
Which TWO of the following are valid ways to create a variable with the integer value 100?
⚠ Common exam trap
Python Institute often tests the distinction between numeric literals (like `100`), string literals (like `'100'`), and type conversion functions (like `int()`), and the trap here is that candidates may mistakenly think a string with digits is automatically an integer or that a float literal like `100.0` is equivalent to an integer.
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
✓
x = int('100')
The `int()` function converts a string containing a valid integer literal, such as '100', into an integer value of 100. This is a standard type-casting operation in Python that explicitly creates an integer from a string representation.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
x = 0100
Why it's wrong here
Leading zero is not allowed (Python 3).
- ✗
x = 100.0
Why it's wrong here
Creates a float, not integer.
- ✓
x = int('100')
Why this is correct
Converts string to integer.
- ✓
x = 100
Why this is correct
Standard integer assignment.
- ✗
x = '100'
Why it's wrong here
This creates a string, not an integer.
Go deeper
Related to this question
About these practice questions
This PCEP question is part of Courseiva's 498-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
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.