PYTHON LESSON 2 OF 32

Variables: your little storage boxes

A variable is a name attached to a value. Think of a labelled box: score = 10 stores 10 under the name score. You can change the value later. Use descriptive names and = for assignment.

हिन्दी में समझें

वेरिएबल किसी मान का नाम है। नाम वाले डिब्बे की तरह score = 10 में score के नाम से 10 रखा है। बाद में मान बदल सकते हैं। मान रखने के लिए = लगाएँ।

अभ्यास: शुरुआती score बदलें ताकि अंतिम score 20 हो।

Hinglish mein samjhein

Variable ek naam wala box hai. score = 10 ka matlab score naam mein 10 save hua. Baad mein value badal sakte ho. Value assign karne ke liye = use karo.

Practice: Starting score badlo taaki final score 20 ho.

A small Python example

score = 10
score = score + 5
print(score)

The browser playground runs real Python with Pyodide. Use sample variables instead of interactive input(). Browser package support differs from desktop Python.

Try this example in the Python playground →

Practise this idea

Change the starting score so the final score is 20.

Check answer & explanation
score = 15
score = score + 5
print(score)

The second statement adds 5. Starting at 15 therefore leaves score equal to 20; = stores the new result.

Stuck in the course? Choose Check answer for either the challenge or quiz. Read the explanation and continue to the next lesson at your own pace.

Check your understanding

What is the final score?

  1. 10
  2. 15
  3. 5
Check the quiz answer

15

The second line adds 5 to the original value of 10.

References & corrections

Use the official Python documentation for full language rules. Read how these lessons are made and checked. Found a mistake? Report it to Excel Keys with this lesson URL and a reproducible example.

FROM LEARNING TO BUSINESS RESULTS

Need a dashboard for your team?

Excel Keys designs custom Excel and HTML dashboards around your own KPIs and Excel files. They run offline in the browser, so your data stays on your computer.