Bird
0
0

What is the correct way to assign the value 100 to a variable named score in Python?

easy📝 Conceptual Q1 of 15
Python - Variables and Dynamic Typing
What is the correct way to assign the value 100 to a variable named score in Python?
Ascore == 100
Bscore = 100
C100 = score
Dscore := 100
Step-by-Step Solution
Solution:
  1. Step 1: Understand variable assignment syntax

    In Python, the variable name comes first, followed by a single equals sign, then the value.
  2. Step 2: Check each option

    score = 100 uses correct syntax: variable name, equals sign, value. 100 = score tries to assign to a value, which is invalid. score == 100 uses double equals which is for comparison, not assignment. score := 100 uses walrus operator which is valid only inside expressions, not for simple assignment.
  3. Final Answer:

    score = 100 -> Option B
  4. Quick Check:

    Variable assignment = score = 100 [OK]
Quick Trick: Use single '=' to assign values to variables [OK]
Common Mistakes:
MISTAKES
  • Using '==' instead of '='
  • Putting value before variable
  • Using ':=' outside expressions

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes