Site icon NetVital

Variables in Python

Python-Variable-Types-logo

Python-Variable-Types-logo

Variables in Programming Language Python

The programing languages store data in the form of Variables. Every variable has data type, name, and a value assigned to it. Variables are assigned places in the computer memory to store data in which they can be known or unknown based on the value given to them. Also, they can be used for more than one value. They can tag and store data in memory and we can recall them when we need them. In this section, we want to introduce the most used Variables in Python. In Python, we have four commonly used groups of variables, which are integers, decimal numbers, strings, and binary (true or false).

  1. int
  2. float
  3. str
  4. bool (binary)

 

Variables in Python – int:

this variable is for integers number such as 0-9:

For example:

We assign number ‘5’ to ‘a’:

If we try to back integers of a float number, we try this command:

also, with can use general math with Python:

Float:

We assign number ‘4.5’ to ‘b’:

 

If we want to have more math command, we can use ‘math’:

String:

We assign ‘hello’ to ‘c’:

for indexing in String, we must now three steps: [start:stop:step], all command to use for String is inside these three steps:

indexing [start:stop:step]

If we want to have more math command, we can use ‘String’:

Bool (binary)

let’s to see video from our YouTube channel

 

If you want to learn more Python, please click here.

Exit mobile version