Bird
0
0

Which of the following expressions correctly checks if variable a is of type int using type()?

easy📝 Conceptual Q1 of 15
Python - Variables and Dynamic Typing
Which of the following expressions correctly checks if variable a is of type int using type()?
Atype(a) == int
Btype(a) = int
Ctype(a) === int
Dtype(a) != int
Step-by-Step Solution
Solution:
  1. Step 1: Understand type comparison syntax

    In Python, to check if a variable's type matches a type, use double equals ==.
  2. Step 2: Evaluate each option

    type(a) == int uses == correctly. type(a) = int uses single equals which is assignment, causing syntax error. type(a) === int uses triple equals which is invalid in Python. type(a) != int checks inequality, not equality.
  3. Final Answer:

    type(a) == int -> Option A
  4. Quick Check:

    Correct type check uses == [OK]
Quick Trick: Use '==' to compare types, not '=' or '===' [OK]
Common Mistakes:
MISTAKES
  • Using '=' instead of '=='
  • Using '===' which is invalid in Python
  • Confusing inequality '!=' with equality

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes