Variables in Python allows us to store a data by assigning it to a name. Variables are used to hold values that can be referenced and manipulated in a program. Python is dynamically typed, meaning you don’t need to specify a variable’s data type when declaring.
To declare a Variables in Python, you simply assign a value to a name using the equals sign
=. Here is an example:
name = "John" age = 20
In an above example, the variable
name is assigned a string value of
"John" and the variable
age is assigned an integer value of
In Python, there are several types of variables that we can use to store and manipulate data. Here are some of the most common types of variables in Python:
Variable names in Python can only include letters, digits, and underscores, but cannot begin with a digit. Variable names must not include any special character like %, $ etc. Since Variable names are case sensitive, so
Age are different variables.
Python supports multiple assignment, which allows you to assign values to multiple variables at once. For Example:
x, y, z = 1, 2, 3 print (x) #Outputs: 1 print (y) #Outputs: 2 print (z) #Outputs: 3
Python also allows us to assign the same value to multiple variales. For Example:
x, y, z = "Mango" print (x) #Outputs: Mango print (y) #Outputs: Mango print (z) #Outputs: Mango
Share This Post!