GCGrowCarrer

Variables and Types

Available

Lesson 1 of 60 · Syntax · Easy

Mastery0% of 85%
1

The big idea

A variable is a name that stores a value so your program can remember it and use it later. In Python, you create a variable by writing a name, an equals sign =, and a value: Python figures out the type of each value for you automatically.

Think of it like this: Think of a variable like a labeled jar: the name on the label is `x`, and the number `5` is what you put inside.
Key words (tap to learn):
2

Read the lesson

A variable is a name that stores a value so your program can remember it and use it later.

In Python, you create a variable by writing a name, an equals sign =, and a value:

age = 20        # a whole number (int)
price = 9.99    # a decimal number (float)
name = "Maya"   # text (str)
is_open = True  # true or false (bool)

Python figures out the type of each value for you automatically. Whole numbers like 20 are called int, decimals like 9.99 are called float, and words inside quotes like "Maya" are called str.

You do not need any extra keywords or semicolons — just write name = value on its own line.

3

Quick check

In Python, which line stores the number 10 inside a variable named score?

4

Your challenge

2 sample tests, 1 hidden

Create a variable named x and set it to 5 (just type x = 5).

Stuck? Get a hint (free)
More learning tools(compare languages, visual guide, related lessons)

Compare with another language

Similar to javascript.variables-types (85% overlap). Variables & primitive types: compare let/const (JS), auto/int (C++), := (Go), let mut (Rust), and column types (SQL).

Visual walkthrough

A diagram, a step-by-step animation, and short captions for Variables and Types.

Mastery0%

Learn this first

Nothing needed - you can start here.