Simple data types and value variables do not need to be declared. Python variables do not need to be declared. you can directly enter: & gt; a10 then your memory has a variable a with a value of 10, its simple data type and value assignment
Variable does not need to be declared
Python variables do not need to be declared. you can enter them directly:
>>>a = 10
Then there is a variable a in your memory. its value is 10 and its type is integer ). Before that, you do not need to make any special declaration, but the data type is automatically determined by Python.
>>>print a>>>print type(a)
The following output is displayed:
10
Here, we learned a built-in function type () to query the type of a variable.
Reclaim variable name
If you want a to store different data, you can directly assign values without deleting the original variables.
>>>a = 1.3>>>print a,type(a)
The following output is displayed:
1.3
We can see another usage of print, that is, print is followed by multiple outputs, separated by commas.
Basic data type
A = 10 # int integer a = 1.3 # float floating point number a = True # True Value (True/False) a = 'Hello! '# String
The above is the most common data type. double quotation marks can also be used for strings.
(In addition, there are scores, characters, plural numbers, and other data types. if you are interested, you can learn)
Summary
Variables do not need to be declared or deleted. they can be recycled directly.
Type (): query data type
Integer, floating point, True Value, string
The preceding section describes the basic data types of Python. For more information, see other related articles in the first PHP community!