HelpContactFor teachers and institutes
>_StemPy Lab
Mock TestsClasses

>_StemPy Lab

Learn. Solve. Code the solutions. Test yourself.

Live examsFree mock exams, timed and rankedEveryone starts together, and your score and rank come the moment it ends.See the exams →

Learn

  • Physics
  • Chemistry
  • Mathematics
  • Biology
  • Python Programming
  • Statistics & Data Science
  • Classes
  • Groups

Practice

  • Problems
  • Quizzes
  • Mock Tests
  • Prepare for an Exam
  • Question Sets
  • Exams
  • Certificates
  • Python Labs
  • AI Practice Generator
  • Student-Created Tests

Community

  • Discussions
  • Resources
  • Notes
  • Glossary
  • Blog

Account

  • Log in
© 2026 senLearn. All rights reserved.HelpAboutContactPrivacy PolicyTerms of UseRefund Policy
  1. Glossary
  2. /Python and data
  3. /Variable (in Python)

What is Variable (in Python)?

In short

A variable is a name that refers to a value stored in the computer's memory. You create one by writing the name, an equals sign and the value, for example speed = 12.

In simple words

The equals sign in Python is assignment: it stores the value on the right under the name on the left. It is not a statement that the two sides are equal. A variable can be changed later, and a name can be used in any calculation. Good names say what they hold, such as speed or mass_kg. The main types of value are integers, floats (numbers with a decimal point), strings (text) and booleans (True or False).

Example

This prints 6.0, the force in newtons when the mass is in kilograms.

Learn it properly

  • Lessons on this topic
  • Test yourself

Related terms

  • Program (in Python)
  • Function (in Python)

← All glossary terms

Learn it in

  1. Boxes with Names: Variables
All lessons on this topic →

Practise

  1. Each of these three programs stops with an error…Easy
  2. Say what the type of each result is, and what value it has. Decide on paper first.Medium
  3. A student wants to swap a and b, and writes…Easy
  4. Trace the programMedium

Quick questions

  1. A student works out the value of expressions made with or, and and not. Pick the…Hard
  2. Four assignments are offered. Each one is tried alone, as a complete program. Which…Hard
  3. A student predicts the type of the result of some expressions. Which of the type tests…Advanced

More Python and data terms

  1. Cell (in a Python notebook)
  2. Class and Special Methods (in Python)
  3. Dictionary (in Python)
  4. For Loop
  5. If Statement (in Python)
  6. Import (Python modules and libraries)
All Python and data terms →

Try it yourself

Python labs run in your browser. Type the code, run it and see what happens.

Open a Python lab