python 第三次-----操作列表

1.  使用for循环处理数据是一种对数据集执行整体操作的不错的方式

2.  magicians=['alice','david','carolina']

           for magician in magicians:

           print(magician.title() + ' ,that was a greak trick')

    print("thank you everyone,that was a great magic show!")

3.  python 函数range()可以生成一系列数字

4.  for value in range(1,5):

       print(value)

5.  a=[]

     for b in range(1,11):

       c=(d**2)

            a.append(c)

       print(a)

6.    列表解析:

       a = [ value**2 for value in range(1,11)]

       print (a)

7.    遍历切片:

       players=['a','b','c','d','e']

            print("here are the first three players on my team")

       for player in players[-3:]

               print(player.title())

8.         复制列表

9.      定义元组(python将不能修改的值称为不可变的,而不可变的列表被称为元组)

 

posted @ 2017-11-25 11:58  猴拔树  阅读(134)  评论(0编辑  收藏  举报