wgz890813 发表于 2018-1-21 15:43:15

第十讲 列表笔记 以及 第五讲练习题重点

Python听课心得体会—第10讲 列表
0 学习到了新的东西,列表 这么一个大工厂,[]中可以置入 多个字符串、整数、浮点数以及混合置入。
1 几种在列表中添加新元素的方法,
a,        append() 使用方法:变量名.append()举例
>>> member = [ 1,2,'love']
>>> member.append('heat')
>>> print(member)


b, extend() 优势:可以列表里面增加列表
>>> member.extend(['stay in shape','initiative'])
>>> print(member)

   
c, insert() 优势:可以在列表的指定位置增加元素
>>> member.insert(1,'beat my goal')
>>> print(member)


第五讲 练习题自己需要注意的地方
0 两种获取数据类型的方法type()和isinstance()优先选择isinstance()因为type()还有其他应用
1 好多新知识
s指代字符串
s.isalnum() 所有字符都是数字或者字母,为真返回True,否则为false
s.isalpha()所有字符都是字母,为真返回True
s.isdigit()所有字符都是数字,为真返回True
s.islower()所有字符都小写,为真返回True
s.isupper()所有字符都大写,为真返回True
s.istitle()所有单词首字母大写,为真返回True
s.isspace()所有字符都是空白字符,为真返回True
2 我第二题写的答案,虽然不如小甲鱼想的全面(小甲鱼刚提到知识点都没有用到里面,-_-||),但作为新手满足了。
temp = input('import a year:')
year = int(temp)
if year % 400 == 0:
    print('this year has 366 days')
else:
    if year % 4 == 0 and year % 100 != 0:
      print('this year has 366 days')
    else:
      print('365 days')
页: [1]
查看完整版本: 第十讲 列表笔记 以及 第五讲练习题重点