Courseiva

print() Function Correct Usage

Which FOUR of the following are correct uses of the print() function?

Quick Answer

The correct answer is the use of print('Hello') because it directly calls the print function with a single string argument, which is the most fundamental and universally accepted syntax in Python 3. This works because the print() function is designed to accept any number of positional arguments and output them to the console, with the default separator being a space and the default end being a newline. On the Certified Entry-Level Python Programmer PCEP exam, this tests your understanding of basic function invocation and the print() function's core behavior, often appearing in questions that distinguish between valid syntax and common mistakes like forgetting parentheses or using incorrect keyword arguments. A frequent trap is confusing the print function with the print statement from Python 2, so remember that in Python 3, print is always a function requiring parentheses. For a quick memory tip, think of print() as a friendly messenger that always needs its parentheses to deliver your message, and you can customize its delivery with sep, end, and file keywords.

⚠ Common exam trap

Python Institute often tests the distinction between Python 2's print statement (no parentheses) and Python 3's print function (requires parentheses), leading candidates to mistakenly select option A as valid.

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

✓

print('Hello', 'World', sep='-')

Option B is correct because print() accepts the keyword argument sep to define the separator between multiple arguments, so print('Hello', 'World', sep='-') outputs Hello-World. Option C is correct because print() can take multiple positional arguments and by default separates them with a single space, producing Hello World. Option D is correct because print('Hello') is the standard way to call print() with a single string argument, outputting Hello followed by a newline. Option E is correct because print() accepts arguments of different types, so print('Hello', 5) outputs Hello 5, converting the integer to its string representation. Option A is not correct because print 'Hello' is Python 2 statement syntax, not a valid call to the print() function in Python 3.

Answer analysis

Option-by-option breakdown

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

  • ✗

    print 'Hello'

    Why it's wrong here

    Python 3 removed the print statement, so print 'Hello' raises a SyntaxError; print now requires parentheses. It is tempting because Python 2 accepted this form, and it would be correct only when running legacy Python 2 code rather than the Python 3 the exam targets.

  • ✓

    print('Hello', 'World', sep='-')

    Why this is correct

    Passing `sep='-'` overrides print()'s default single-space separator, so the two arguments are joined with a hyphen and the output is `Hello-World`. This satisfies the stem's requirement for a correct use of print(), since `sep` is a valid keyword argument controlling the separator inserted between multiple positional arguments.

  • ✓

    print('Hello', 'World')

    Why this is correct

    Passing multiple arguments separated by commas makes print() output them with a single space between each, producing "Hello World". This satisfies the stem's requirement for a correct use, since print() accepts any number of positional arguments and joins them automatically.

  • ✓

    print('Hello')

    Why this is correct

    Passing a single string literal to `print()` writes it to standard output followed by a newline, satisfying the requirement that `print()` accepts string arguments. This is the function's most basic documented use, so `print('Hello')` correctly displays Hello.

  • ✓

    print('Hello', 5)

    Why this is correct

    Passing multiple arguments separated by commas makes `print()` output them with a single space between each, so this displays `Hello 5`. This satisfies the stem's requirement for a correct use, since `print()` accepts any number of positional arguments and converts non-string values such as the integer `5` automatically.

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

Same concept, more angles

1 more way 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. Order the steps to debug a Python script using print statements.

medium
  • ✓ A.1. Insert print statements, 2. Run the script, 3. Analyze the output, 4. Remove print statements
  • B.1. Insert print statements, 2. Remove print statements, 3. Run the script, 4. Analyze the output
  • C.1. Run the script, 2. Insert print statements, 3. Analyze the output, 4. Remove print statements
  • D.1. Analyze the output, 2. Insert print statements, 3. Run the script, 4. Remove print statements

Why A: Debugging with print involves inserting prints, running, analyzing, and cleaning up.

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.