Python learning notes-basic data types, python learning notes
1: variables do 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
>>> Print type ()
The following output is displayed:
10
<Type 'int'>
Here, we learned a built-in function type () to query the type of a variable.
2: 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 ()
The following output is displayed:
1.3 <type 'float'>
We can see another usage of print, that is, print is followed by multiple outputs, separated by commas.
3: 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)
4: Conclusion
Variables do not need to be declared or deleted. They can be recycled directly.
Type (): query data type
Integer, floating point, true value, string