Python data type:
Number type:
int integer type For example: Age=18 #定义时会自动辨认, the actual input is Age=int (18)
float float type For example: height=1.80 #实际输入的是 height=float (1.80)
String type:
In Python, the string type is added.
Example: Name= ' Xuzuo ' #实际输入的是name =str (' Xuzuo ')
Single quotes, double quotes, and multiple quotation marks can be defined when a string type is defined. There is no difference between single and double quotes, but only in special time, for example: info= "I am xuzuo,i ' am very cool" #这种情况用单双引号来区分开.
Multiple quotation marks are used to define values with multiple lines of string.
Example: info= "" "
Name: Continued
Hobbies: Games, sister
Additional hobbies: Nothing nonsense, sleep
"""
Print (info) #输出info变量的值
List type
#在 [] separated by commas, you can store n any type of value
For example:
info=[' name ', ' age ', ' sex ' #定义一个info的列表
Print (info[0]) #列表输出第一个定位符是0, followed by and so on. The output is: Name
List nesting
info=[' name ', ' age ', [' read ', ' Music ']] #列表中嵌套列表
Print (info[2][0]) #输出结果为: Read
Dictionary type
Why use a dictionary when you have a list?
The dictionary can be valued by the corresponding key.
For example:
info={' name ': ' Xuzuo ', ' age ': +, ' hobbies ': [' read ', ' Musci ', ' Play games '} #定义字典并嵌套列表
Print (info[' name '],info[' Hobbies '][2]) #输出结果为: Xuzuo play games
Boolean type
There are only two Boolean values: True False #真和假
Computer is commonly known as computer, that is, we write a program to let the computer run, it should be to let computers infinitely close to the human brain, or what the human brain can do, what the computer should be able to do, the main role of the brain is data operation and logic operations, here the Boolean type of simulation of the logic of human operation, that is, when Use True to identify, not set, and false.
For example:
A=5
b=10
If a < b: #判断a是否大约b, if yes
Print (' result is true ') #如果是则输出print中的字
else: #如果不是
Print (' result is false ') #如果不是输出print中的字
Python Basics-Data types