Python programming language provides different data types in order to use data in applications. We generally use variables in order to store our data. As the name suggests variables can be changed during their lifetime. In this tutorial we will look different features and options of Python variables.
Create and Assign Value To Variable
Assigning some value to a variable in Python is very easy. We will use equal
operator in order to do this job. We will put variable name to the left side and put the data right side of the equal sign. This will also create new variable with the given name.
In this example we will create a variable named myname
which will hold a name which is a text data.
myname = "poftut com"
Multiple Assignment
Python provides a lot of shortcuts and practical use cases to make things faster. One of them is multiple assignment. We can assign single value into multiple variables. We will just provide multiple variable names to the left side by separating them with equal
sign and the last value will be the value we want to assign all of these variables.
In this example we will assign 3
to variables named count
, length
, size
variables.
count = length = size = 3
Primitive Data Types
Python provides a lot of data types but we can group them as primitive and complex. Primitive data types provides simple and easy to use data and have less functions. Here the list of primitive data types
Complex Data Types
Complex data types holds more compound data and provides a lot of functions to get, set and manage data inside this type of variables. Here list of complex or compound data type.