fruit = ['apple','banana','peach']
print fruit[0],fruit[-1] fruit_1 =[]
fruit_1.append('orange')
print fruit_1 fruit.insert(1,'orange')
del fruit[2]
print fruit '''
apple peach
['orange']
['apple', 'orange', 'peach']
''' pop_1 = fruit.pop(1)
print pop_1,"\n",fruit '''
orange
['apple', 'peach']
''' apple = 'apple'
fruit.remove(apple)
print fruit,"\n",fruit_1 '''
['peach']
['orange']
''' fruit_2 = ['a','b','c','d','e','f']
fruit = fruit_1 + fruit_2
print fruit '''
['orange', 'a', 'b', 'c', 'd', 'e', 'f']
'''
new_fruit = sorted(fruit,reverse=True)
print fruit,"\n",new_fruit
new_fruit.sort(reverse=True)
print new_fruit
new_fruit.reverse()
print new_fruit '''
['orange', 'a', 'b', 'c', 'd', 'e', 'f']
['orange', 'f', 'e', 'd', 'c', 'b', 'a']
['orange', 'f', 'e', 'd', 'c', 'b', 'a']
['a', 'b', 'c', 'd', 'e', 'f', 'orange'] ''' length = len(new_fruit)
print length # #empty = []
#iprint empty[-1] '''
Traceback (most recent call last):
File "t.py", line 61, in <module>
print empty[-1]
IndexError: list index out of range
''' for i in new_fruit:
print i
print i '''
a
b
c
d
e
f
orange
orange
''' new_list = list(range(1,15,3))
print new_list #[1, 4, 7, 10, 13] max_in_list = max(new_list)
min_in_list = min(new_list)
sum_in_list = sum(new_list)
print max_in_list,"\n",min_in_list,"\n",sum_in_list '''
13
1
35
'''
double=[i**2 for i in range(1,20)]
new_double = double[:]
print new_double
print double[4:] #[1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, 361]
#[25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, 361] for single in double[5:-1]:
print single '''
36
49
64
81
100
121
144
169
196
225
256
289
324
'''
new_double_2 = double
double.pop(0)
print double
print new_double_2
print new_double '''
[4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, 361]
[4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, 361]
[1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, 361]
''' new_double[1] =2500000000000
print new_double #[1, 2500000000000, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, 361] scale = [1,8]
for number in scale:
print number scale = (1,8)
for number in scale:
print number '''
1
8
1
8
'''

问题:列表可以用[ ]or( )???

 scale = [1,8]
for number in scale:
print number scale = (1,8)
for number in scale:
print number '''
1
8
1
8
'''

最新文章

  1. 【手记】注意BinaryWriter写string的小坑——会在string前加上长度前缀length-prefixed
  2. UART
  3. Facebook的Hack语言三大看点
  4. hive查询
  5. js获取服务器时间戳
  6. phpcms 02
  7. Html.Listbox的用法(实例)
  8. cp: omitting directory”错误的解释和解决办法
  9. Node.js 创建第一个应用
  10. 第三篇:gradle 编译 Android app 概览
  11. 如用使用高版本framework,比如支持iOS5及以上的工程中使用Social.framework
  12. PHP接入阿里云市场 阿里短信服务DEMO
  13. 【高斯消元】兼 【期望dp】例题
  14. BZOJ 3771: Triple [快速傅里叶变换 生成函数 容斥原理]
  15. gethostbyname(domain) 老是返回 NULL, 凌乱了
  16. cocos2d JS-(JavaScript) 冒泡排序
  17. 170825、SolrCloud 分布式集群部署步骤
  18. IT资源关东煮第一期【来源于网络】
  19. 用户定义的java计数器
  20. swift 快速创建一些基本控件

热门文章

  1. oo第四单元及课程总结
  2. SQL SERVER 2012 OBJECT_ID
  3. c++程序—变量
  4. VC++ DLL 3 动态链接库
  5. Q4:Median of Two Sorted Arrays
  6. 计算机网络(1): http原理和uuid
  7. 十二、GUI设计-画图程序
  8. plt画log图
  9. 简单的Vue计算属性
  10. 对PHP-GC(垃圾回收)的一点理解