Home >Backend Development >Python Tutorial >Introduction to basic data types in Python
Simple Data typesand assignment
VariablesNo need to declare
PythonVariables do not need to be declared, You can directly enter:
>>>a = 10
Then you will have a variable a in your memory, its value is 10, and its type is integer (integer) . You don't need to make any special declarations before this, and the data type is automatically determined by Python.
>>>print a >>>print type(a)
Then there will be the following output:
10
5fda8a223f71985e492b1a73f0e36905
Here, we learn a built-in Function type(), used to query the type of variables.
RecyclingVariable name
If you want a to store different data, you can assign it directly without deleting the original variable.
>>>a = 1.3 >>>print a,type(a)
There will be the following output
1.3 fd185118e90007bda1e0957bca462925
We see another usage of print, which is print Follow by multiple outputs, separated by commas.
Basic data types
a=10 # int 整数 a=1.3 # float 浮点数 a=True # 真值 (True/False) a='Hello!' # 字符串
The above are the most commonly used data types. For strings, double quotes can also be used.
(In addition, there are other data types such as fractions, characters, plurals, etc. If you are interested, you can learn about it)
Summary
Variables do not need to be declared or deleted, you can Direct recycling applies.
type(): Query data type
Integer, floating point number, true value, string
The above is the detailed content of Introduction to basic data types in Python. For more information, please follow other related articles on the PHP Chinese website!