博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Python学习第七天
阅读量:6895 次
发布时间:2019-06-27

本文共 1144 字,大约阅读时间需要 3 分钟。

hot3.png

#!/usr/bin/python

#filename :test7.py

# Part one:Python list

list1 = ['physics','chemistry',1997,2000];

list2 = [1,2,3,4,5,6,7];

print ("list1[0]:",list1[0])

print ("list2[1:5]:",list2[1:5])

print ("list1[2]:",list1[2])

list1[2] = 10000

print ("after update the value list1[2]:",list1[2])

print (list1)

del list1[2]

print ("after deleting value at index 2:")

print (list1)

print (len(list1))

print (list1+list2)

print (list1*4)

print (2000 in list1)

for x in list1:

print (x)

print (list1.append(1))

print ("new list1 : ",list1)

print ("list1.count(1) :",list1.count(1))

print ("list1.index(1) :",list1.index(1))

# Part two : Python tuple

tup1 = ('physics','chemistry',1997,2000)

tup2 = (1,2,3,4,5,6)

tup3 = 'a','b','c','d'

print (tup1)

print (tup2)

print (tup3)

tup4 = ()

tup5 = (50,)

print (tup4)

print (tup5)

# the values of tuple are not allowed changing

#tup1[0] =100

tup6 = tup4 + tup5;

print (tup6);

del tup6

print ("after deleting tup:")

#print (tup6)    # is not defined

print (len((1,2,3)))

print ((1,2,3)+(4,5,6))

print ('abc',-4.21,18+6.6,'xyz')

x,y = 1,2

print ('value of x , y :',x,y)

转载于:https://my.oschina.net/u/2329222/blog/612587

你可能感兴趣的文章
打印沙漏
查看>>
c#接口
查看>>
"只能在执行Render()的过程中调用RegisterForEventValidation" 解决方案
查看>>
vue中页面跳转拦截器的实现方法
查看>>
MySql连接异常解决
查看>>
mongodb Limit操作
查看>>
百度地图api
查看>>
unbuntu14.04下的串口软件monicom的使用
查看>>
SQLite实践
查看>>
Jmeter分布式
查看>>
SQLserver数据库还原后显示"正在还原"
查看>>
Python基础-1
查看>>
js操作cookie
查看>>
[AutoCars(一)]自动驾驶汽车概述(上)
查看>>
jquery基础研究学习【HTML】
查看>>
几个C# Visual Studio编码技巧
查看>>
sql数据库各个版本清除日志
查看>>
jQuery扩展两类函数(对象调用,静态调用)
查看>>
nofollow标签使用方法
查看>>
sqlite实现新闻收藏和取消收藏
查看>>