The role of the five data types Python 1. Briefly, the defined manner using the method:
1. Digital Type
Role: Describes the age / weight / id
Defined way: int long float
Use: + - * / ** //%
2. String type
Role: Description Name / single Hobbies / gender
Defined way: string
Use: + *
3. List
Action: storing a plurality of (of any data type)
Defined method: list [] the use, a plurality of spaced elements (of any data type)
Use: cable (search) lead (lead the way)
4. Dictionary
Action: storing a plurality of values, each value by the description but
Is defined by: {} are better separated by the plurality of keys (to be described) values (specific values) of
Use: dictionary not indexed
5. Boolean
Role: True or false
Defined method: Boolean only two values, one is True, the other is False, Boolean values do not print directly, but triggered under certain conditions
Use: True or False
2. The following line of code to implement the functions of the code implementation:
x = 10
y = 10
z = 10
print('x=',10,'\n','y=',10,'\n','z=',10)
3. Write two ways exchange x, y values:
x = 10
y = 20
#第一种
x = 10
y = 20
z=x
x=y
y=z
#第二种
x,y=y,x
4. Remove the line of code nick
of 3 interests:
nick_info_dict = {
'name':'nick',
'age':'18',
'height':180,
'weight':140,
'hobby_list':['read','run','music','code'],
}
print(nick_info_dict['hobby_list'][1],nick_info_dict['hobby_list'][2])
5. Use the formatted output of three ways to achieve the following outputs (name changed to his name, acquired modify height and weight, do not brazen)
name = 'Nick'
height = 100
weight = 420
# "My name is 'Nick', my height is 180, my weight is 140"
name = 'JimGraymane'
height = 181
weight = 140
print(f'My name is {name}, my height is {height},my weight is {weight}')