python basics DAY_3

Insert picture description here
(1)

RAM
100
200
300

(2)

a=list(range(30,90,10))

(3)

[0, 18, 36, 54, 72, 90, 108, 126, 144, 162, 180, 198]

(4)
r1=dict(Name='Senior Primary One', Age=18, Salary=30000, City='Beijing')
r2=dict(Name='Senior Primary Two', Age=19, Salary=20000, City ='Shanghai')
r3=dict (name='high school five', age=20, salary=10000, city='Shenzhen')
a=[r1,r2,r3]
Insert picture description here
(5)

Tuples and lists belong to ordinal sequence, but tuples are immutable

(6)

c=dict (payment amount=300, payment date='2018.10.18', payer='Gao Xiaoqi')

(7)

r1=dict(name='high school one', age=18, salary=30000, city='Beijing')
r2=dict(name='high school two', age=19, salary=20000, city='Shanghai ')
r3=dict(name='high school five', age=20, salary=10000, city='Shenzhen')
tb=[r1,r2,r3]

(8)
Insert picture description here

(9) Sets and dictionaries have in
common:
① Both use brackets {}
② Both are unordered data collections
Both are variable
Differences:
storage objects are not the same
  dictionary is a collection of "key-value" pairs, dictionary The "value" (key) is referred to by the "key" (value). The key is generally unique. If the last key-value pair is repeated, the previous one is replaced. The value does not need to be unique, and the key can store any type of object.
  The collection does not support subscript index. It is a variable data type. The elements in the collection are unique, and lists and dictionaries cannot be stored. They are generally used for elements in tuples or lists.

Guess you like

Origin blog.csdn.net/tjjyqing/article/details/113104426