W3schools Sign Up
Python Tutorial

Python Variables

Creating Variables

Variables are containers for storing data values. Python has no command for declaring a variable. A variable is created the moment you first assign a value to it.

Example

x = 5 y = "John" print(x) print(y)

Variable Names

A variable can have a short name (like x and y) or a more descriptive name (age, carname, total_volume). Rules for Python variables:

A variable name must start with a letter or the underscore character, and cannot start with a number. Variable names are case-sensitive (age, Age and AGE are three different variables).

Assign Value to Multiple Variables

Example

x, y, z = "Orange", "Banana", "Cherry" print(x) print(y) print(z)