Python Variables
Overview
Let’s learn about Python variables in this tutorial. A Variable is a memory space reserved in computer memory to store a value, and that value can be changed further during program execution if needed. This means that when we create a variable, we reserve some space in memory depending upon the type of value. Each value assigned to a variable has a data type. Variables are used by assigning them a value.
Dynamic Typing
Python is a dynamically typed language, meaning the variable type is determined at runtime. We do not need to define the variable type in Python while declaring it. The interpreter implicitly binds the value with its type. This also means that a variable can be reassigned to a different type.
Variable Names
There are some rules in Python to name the variables used in the programs. For example, variable names can start with a letter or an underscore character. Variable names cannot start with a number.
Python is a case-sensitive language. So, the variable names with upper and lower case are different. Python variable names can only contain alpha-numeric characters and underscores (A-z, 0-9, and _ ).
Creating Variables
As explained, we can create variables by declaring them and assigning values. The declaration happens automatically when you assign a value to a variable. The equal sign (=) is used to assign values to variables.
# Creating variables
x = 100 # number
y = 76.9 # floating point
website = “TestingDocs.com” # string variable
—
Python Tutorials
Python Tutorial on this website can be found at:
https://www.testingdocs.com/python-tutorials/
More information on Python is available at the official website: