Python variable types


  Translation results:

The variable stores the value in memory. This means that when a variable is created, a space is created in memory.

Based on the data type of the variable, the interpreter allocates the specified memory and determines what data can be stored in the memory.

Therefore, variables can specify different data types, and these variables can store integers, decimals, or characters.

Python variable typessyntax

Variable assignment in Python does not require a type declaration.

Each variable is created in memory and includes information such as the variable's identification, name and data.

Each variable must be assigned a value before use. The variable will not be created until the variable is assigned a value.

The equal sign (=) is used to assign values ​​to variables.

The left side of the equal sign (=) operator is a variable name, and the right side of the equal sign (=) operator is the value stored in the variable.

Python variable typesexample

#!/usr/bin/python
# -*- coding: UTF-8 -*-
counter = 100 # Assign integer variable
miles = 1000.0 # Floating point type
name = "John" # string
print counter
print miles
print name

Popular Recommendations

Home

Videos

Q&A