How to Declare a Variable in Python?

Amansingh Javatpoint
1 min readJun 11, 2021

The concept of constants and variables is something that we are studying right from our primary classes. We know that constants are the fixed values whereas variables are those whose values can be changed or varied.

In this article, we will discuss how to declare a variable in python.

Declaring a variable in Python programming language is a demonstration of the steps that we discuss in the algorithms.

They are the containers that can hold values of any datatype and occupy a space in the memory.

Let us have a look at the naming convention of our variables that makes them an authentic one-

Following are the rules that we must take care of-

  1. The name of our variable can have an underscore ( _ ).
  2. The name of the variable should not contain any special character.
  3. The name of the variable should not be a keyword.

We will discuss the given examples that will help us to understand the different ways of declaring a variable.

  1. A simple assignment of values to variables.
  2. Assigning values to variables in the same line.
  3. Assigning a single value to three variables at a time.

Let us have a look at the first example where we have assigned an integer value, a float value, and a string value to the variables a,b, and c respectively.

--

--