![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
python
Zend0
这个作者很懒,什么都没留下…
展开
-
python核心编程 练习题 石头剪刀布
# -*- coding:UTF-8 -*- import random # def game(): menu = '\ 选择以下命令出拳:\n(s)石头\n(j)剪刀\n(b)布\n' cmds = ['石头','剪刀','布'] usrinput = raw_input(menu).strip() cptinput = random.choice(cmds) if usrinp原创 2014-05-16 11:03:48 · 2160 阅读 · 0 评论 -
python核心编程第三章练习题12
import osdef makeTextFile():while True:linesep=os.linesepfname = raw_input("type the file name to write\n(move back by 'q'): ")if fname.strip().lower() == 'q':breaktry:fobj = open(fname,'r')except IOE原创 2014-05-17 10:51:04 · 1371 阅读 · 0 评论 -
python的深复制和浅复制
# -*- coding:UTF-8 -*- #此次练习主要是讨论对象的浅复制和深复制 import copy #浅复制一个object有三种方式:1、slice操作; # 2、copy模块的copy函数; # 3、工厂函数:dict()、list()、tuple() #*******************原创 2014-05-17 10:54:49 · 972 阅读 · 0 评论 -
python核心编程第六章练习题答案 (2,3,5,6,7,8,12,13,14,16)
#6-2 import random lists=[] for i in range(0,random.randrange(0,101)): n = random.randrange(0,2**31) lists.append(n) while True: try: newlist =[] for i in range(0,random.randrange(0,101)):原创 2014-05-20 19:33:46 · 2656 阅读 · 3 评论 -
python核心编程 第五章练习题答案(简单的没上)
#习题5-5 while True: usr = int(eval(raw_input('Enter your $cents: ').strip())) while usr in range(0,101): break else: print 'OverIndex~!' usr = int(eval(raw_input('Enter your $cents: ').strip(原创 2014-05-20 19:22:57 · 1224 阅读 · 0 评论