在Python环境下,用列表定义:
>>> stu1=['xiaoming',True,21,79.9]
>>> stu1=['lihong',False,22,69.9]
>>> stu1=['zhangqiang',True,20,89.9]
>>> stu1=['EMT',True,23,99.9]
如图,定义了四个列表,分别存储了4个学生的姓名、性别,年龄和成绩:
在Python环境下,用字典定义:
>>> stu1={'name':'xiaoming','sex':True,'age':21,'score':69.9}
>>> stu2={'name':'lihong','sex':False,'age':22,'score':79.9}
>>> stu3={'name':'lihong','sex':True,'age':20,'score':89.9}
>>> stu4={'name':'EMT','sex':True,'age&