Courseiva
Question 8 of 498
Data Types, Variables, Basic I/O and OperatorshardMultiple ChoiceObjective-mapped

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

A function sometimes returns None. Which expression correctly checks if the return value is not None?

⚠ Common exam trap

Python Institute often tests the distinction between identity (`is`) and equality (`==`) operators, and the trap here is that candidates mistakenly use `!= None` (value comparison) instead of `is not None` (identity comparison), or confuse truthiness checks with `None` checks.

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

if val is not None:

The `is not` operator is the proper way to check identity inequality in Python. Since `None` is a singleton, comparing with `is not` ensures you are checking whether the value is literally the `None` object, which is the recommended and most readable approach for `None` checks.

Answer analysis

Option-by-option breakdown

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

  • if not val is None:

    Why it's wrong here

    Works but less readable.

  • if val != None:

    Why it's wrong here

    Works but not idiomatic; PEP 8 recommends 'is not'.

  • if val is not None:

    Why this is correct

    Correct and idiomatic.

  • if val:

    Why it's wrong here

    False if val is None, also false for 0, empty string, etc.

About these practice questions

Courseiva creates original exam-style practice questions with explanations and wrong-answer analysis. It does not publish real exam questions, exam dumps, or protected exam content. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

Last reviewed: Jun 30, 2026

Question Discussion

Share a tip, memory trick, or ask about the reasoning behind this question. Do not post real exam questions, leaked content, braindumps, or copyrighted exam material. Comments are moderated and may be removed without notice.

Loading comments…

Sign in to join the discussion.

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.