Member-only story

Variables in Python with Examples

Bipsmedium
4 min readJul 29, 2022

--

Variables in Python are declared using some set of rules as given below

  • When you declare a variable in Python then it must start with a letter or underscore character.
  • You can not start with numbers or digits while declaring Python variables.
  • The variables consist of alphabets and numbers i.e. alphanumeric characters and underscore such as [A-Z, a-z, 0–9, _].
  • There is no keyword or command for creating python variables like other programming languages. We can directly put the variable name such as x, y, etc.
  • Python variables are case sensitive as ( phone, Phone, and PHONE) are three different variables.

Below are some examples of variables in Python

Example 1:-

a = 5 
b= 10
print(a) print(b)

Output:-

5
10

Example 2:-

a = 5

a = 5.3

print(a)

Output:- 5.3

Example 3:-

name = Tom 
Name = Dick
NAME = Herry
print(name)
print(Name)
print(NAME)

Output:-

File “d:\python\python_programming\01_python.py”, line 38, in
name = Tom
NameError: name ‘Tom’ is not defined

--

--

Bipsmedium
Bipsmedium

Written by Bipsmedium

Hi, This is Biplab and I am a PHP laravel developer and other open source technologies. I am here to share my experience with the community.

No responses yet