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:
Step 1: Understand variable assignment syntax
In Python, the variable name comes first, followed by a single equals sign, then the value.
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.
Final Answer:
score = 100 -> Option B
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
Master "Variables and Dynamic Typing" in Python
9 interactive learning modes - each teaches the same concept differently