Courseiva

PCEP Practice Question: Data Types, Variables, Basic I/O and Operators

Exhibit

Refer to the exhibit.

```python
a = 10
b = 3
print(a / b)
print(a // b)
print(a % b)
```

Refer to the exhibit. Which of the following shows the correct output?

⚠ Common exam trap

Watch out — candidates often confuse the behavior of the `/` operator (which always returns a float in Python 3) with integer division from Python 2, or they misapply floor division and remainder operations, especially when dealing with positive integers.

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

✓

3.3333333333333335 3 1

The code `print(10/3)` performs floating-point division in Python 3, yielding `3.3333333333333335`; `print(10//3)` performs floor division, which truncates to the nearest integer less than or equal to the result, giving `3`; and `print(10%3)` computes the remainder of the division, which is `1`.

Answer analysis

Option-by-option breakdown

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

  • ✗

    3.3333333333333335 4 1

    Why it's wrong here

    The values shown misstate Python's arithmetic and type behaviour: true division of 10 by 3 yields 3.3333333333333335, but integer division and modulo outputs differ from those listed. This option tempts because it mirrors the division result, yet the remaining lines are wrong.

  • ✓

    3.3333333333333335 3 1

    Why this is correct

    Python's `/` operator always performs true division, yielding a float, so `10/3` produces 3.3333333333333335. The `//` operator performs floor division, truncating toward negative infinity, giving `10//3 == 3`. The `%` operator returns the remainder, so `10%3 == 1`. Printing each result on its own line matches the exhibit's expected output exactly.

  • ✗

    3.0 3.0 1.0

    Why it's wrong here

    Python 3's / operator returns a float, so 10/3 gives 3.3333333333333335, not 3.0. The option is tempting because it correctly shows floats, but the actual quotient is not a whole number, so the first value is wrong.

  • ✗

    3 3 0

    Why it's wrong here

    Integer division truncates, so 10/3 yields 3, not 3.0, and the subsequent operations produce integers throughout. The option is tempting because the first value looks right, but printing 3.0 and 1.0 requires true division, which Python 3's / operator performs.

About these practice questions

This PCEP question is part of Courseiva's 482-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 →

How Courseiva writes practice questions · Editorial policy

Same concept, more angles

8 more ways this is tested on PCEP

These questions test the same concept from different angles. Work through them to make sure you can recognise it however the exam phrases it.

Variation 1. What is the output of print(10 // 3, 10 % 3)?

medium
  • A.1 3
  • B.3.33 1
  • C.3 3
  • ✓ D.3 1

Why D: The // operator performs floor division, which divides 10 by 3 and discards the fractional part, yielding 3. The % operator returns the remainder of that division, which is 1. The print function outputs both values separated by a space, resulting in '3 1'.

Variation 2. Which two of the following expressions return the value 5? (Choose two.)

hard
  • A.10 % 5
  • ✓ B.10 // 2
  • C.10 ** 0
  • D.10 / 2
  • ✓ E.5 * 1

Why B: Option B, 10 // 2, is correct because // is Python's floor-division operator, and 10 // 2 evaluates to the integer 5. Option E, 5 * 1, is correct because multiplication of 5 by 1 yields the integer 5. Option A, 10 % 5, is not correct because % is the modulo operator and 10 % 5 returns the remainder 0, not 5. Option C, 10 ** 0, is not correct because ** is exponentiation and any nonzero number raised to the power 0 equals 1. Option D, 10 / 2, is not correct because / is true division in Python 3 and returns the float 5.0, not the integer value 5.

Variation 3. Given 'a = 10; b = 3; c = a // b; d = a % b', what is the value of c + d?

hard
  • ✓ A.4
  • B.5
  • C.7
  • D.6

Why A: In Python, the // operator performs floor division, so a // b = 10 // 3 = 3. The % operator returns the remainder, so a % b = 10 % 3 = 1. Therefore, c + d = 3 + 1 = 4, making option A correct.

Variation 4. Refer to the exhibit. What is the output?

easy
  • A.3.0 1.0
  • B.3 3
  • C.3.333 1
  • ✓ D.3 1

Why D: The code in the exhibit is `print(10//3, 10%3)`. The `//` operator performs floor division, which for positive numbers truncates the decimal part, so `10//3` yields 3. The `%` operator returns the remainder of the division, `10%3` yields 1. Thus the output is '3 1'.

Variation 5. Which operator performs integer (floor) division in Python?

easy
  • ✓ A.//
  • B.%
  • C./
  • D.**

Why A: The // operator performs integer (floor) division in Python, which divides two numbers and returns the largest integer less than or equal to the result. For example, 7 // 2 returns 3, not 3.5, because it discards the fractional part and rounds down toward negative infinity for negative numbers.

Variation 6. What is the output of: print(10 // 3, 10 % 3)?

easy
  • A.3.3333 1
  • ✓ B.3 1
  • C.3.0 1.0
  • D.1 3

Why B: The // operator performs floor division, returning the integer quotient (10 // 3 = 3), and the % operator returns the remainder (10 % 3 = 1). The print function outputs these two values separated by a space.

Variation 7. Which operator is used for integer division in Python?

easy
  • A.%
  • B.**
  • C./
  • ✓ D.//

Why D: The // operator in Python performs floor division, which returns the integer quotient after dividing two numbers, discarding any fractional remainder. For example, 7 // 2 yields 3, not 3.5, making it the explicit integer division operator.

Variation 8. What is the output from the interactive Python session?

easy
  • A.3.333 1
  • ✓ B.3 1
  • C.1 3
  • D.3 0

Why B: The expression `10 // 3` performs integer (floor) division, which discards the fractional part and returns the integer quotient 3. The expression `10 % 3` returns the remainder of the division, which is 1. Therefore, the output is `3 1`, making option B correct.

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.