Learn with Yasir

Share Your Feedback

True vs False in Python Variables | Practice & Progress Guide


Master Python boolean variables with hands‑on exercises! Learn how to use True and False, explore type() and id(), and test your understanding with self‑grading practice questions.

🔍 True or False

🟢 Beginner

  1. Variable names in Python are case-sensitive.
  2. Answer

    ✅ True – Python treats uppercase and lowercase letters as distinct (e.g., `myVar` and `myvar` are different variables).


  3. In Python, variables must be declared with a specific data type before they can be used.
  4. Answer

    ❌ False – Python uses dynamic typing - variables are created when first assigned a value, without explicit type declaration.


  5. The statement `x = 5` both creates the variable x and assigns it the value 5.
  6. Answer

    ✅ True – In Python, assignment to a new variable name automatically creates that variable.


  7. Python variable names can start with a number.
  8. Answer

    ❌ False – Variable names must start with a letter (a-z, A-Z) or underscore (_).


  9. `x = y = 5` is a valid way to assign the same value to multiple variables.
  10. Answer

    ✅ True – Python allows chained assignments in a single line.


  11. Variables must be explicitly deleted using `del` to free memory.
  12. Answer

    ❌ False – Python's garbage collector automatically handles memory management.


  13. `None` is the same as `False` in Python.
  14. Answer

    ❌ False – `None` is a distinct object representing 'no value', while `False` is a boolean.


🟡 Intermediate

  1. Python is a statically typed language.
  2. Answer

    ❌ False – Python is dynamically typed - variable types are checked at runtime.


  3. A variable can hold an integer first, then a string later in the same program.
  4. Answer

    ✅ True – Dynamic typing allows variables to change types during execution.


  5. `type()` function returns the current type of a variable.
  6. Answer

    ✅ True – `type(x)` shows the type of object `x` currently references.


  7. A function without a `return` statement returns `None`.
  8. Answer

    ✅ True – Python functions implicitly return `None` if no return statement exists.


  9. `x = None` is equivalent to not defining `x` at all.
  10. Answer

    ❌ False – `x = None` creates a variable bound to the `None` object, while an undefined variable raises a `NameError`.


  11. In Python, `a = b` creates a copy of `b`'s value.
  12. Answer

    ❌ False – Assignment creates a new reference to the same object (aliasing), not a copy.


🔴 Advanced

  1. `None` occupies zero bytes in memory.
  2. Answer

    ❌ False – `None` is a singleton object that does occupy memory (like any Python object).


  3. `None` can be used as a dictionary key.
  4. Answer

    ✅ True – `None` is hashable and can be used as a key, unlike mutable objects.


📚 Related Resources