2018年6月13日

递归,汉诺塔游戏

摘要: def hanoi(n,a,b,c): if n==1: print(n,a+'->'+c) else: hanoi(n-1,a,c,b) print(n,a+'->'+c) hanoi(n-1,b,a,c) hanoi(7,'A','B','C') 阅读全文

posted @ 2018-06-13 20:27 沈烨纯 阅读(100) 评论(0) 推荐(0)

2018年6月6日

列表、元组、字典、集合的定义、操作与综合练习

摘要: totalstr = '201709080001郑裕彤 201709080002张可 201709080003余君妍 201709080005黄颖琪 201709080012何倩仪 201709080013曾焕豪 201709080027许文杰' totalList = totalStr.split(' ') totalSet = set(totalList) print(totalList) ... 阅读全文

posted @ 2018-06-06 21:42 沈烨纯 阅读(138) 评论(0) 推荐(0)

2018年5月30日

文件操作,列表实例NiceHexSpiral

摘要: fr = open('1233.txt',mode='r', encoding='utf-8') plaincode=fr.read() print('明文:'+ plaincode) print('密文:',end='') for c in plaincode: print(chr(ord(c)+3),end='') fr = open('1233.txt',mode='r', e... 阅读全文

posted @ 2018-05-30 21:27 沈烨纯 阅读(109) 评论(0) 推荐(0)

2018年5月23日

字符串操作

摘要: id='445122199811080042' area=id[0:6] birthday=id[6:14] sex=id[-2] print(area,birthday,sex) if(int(sex)%2==0): print('girl') else: print('boy') print(ord('+')) print(chr(9800)) print(chr(98... 阅读全文

posted @ 2018-05-23 20:56 沈烨纯 阅读(120) 评论(0) 推荐(0)

2018年5月16日

函数定义与使用

摘要: import turtle turtle.setup(600,400,0,0) turtle.bgcolor('red') turtle.color('yellow') turtle.fillcolor('yellow') def mygoto(x,y): turtle.penup() turtle 阅读全文

posted @ 2018-05-16 20:37 沈烨纯 阅读(75) 评论(0) 推荐(0)

2018年5月9日

for循环:用turtle画一颗五角星

摘要: >>> import turtle >>> turtle.penup() >>> turtle.left(90) >>> turtle.fd(200) >>> turtle.pendown() >>> turtle.right(90) >>> turtle.fillcolor("red") >>> turtle.begin_fill() >>> turtle.circle(10, 180) >>... 阅读全文

posted @ 2018-05-09 21:07 沈烨纯 阅读(182) 评论(0) 推荐(0)

程序执行流程/布尔类型与布尔:运算猜数字游戏;库的使用:turtle

摘要: myNumber = 9 while True: guess = int(input()) if guess > myNumber: print('>') elif guess >> import turtle >>> turtle.up() >>> turtle.goto(0,-200) >>> turtle.down() >>> turtle.cir... 阅读全文

posted @ 2018-05-09 20:00 沈烨纯 阅读(86) 评论(0) 推荐(0)

2018年4月30日

条件语句,while循环语句:完整的温度转换程序

摘要: a=int(input('摄氏温度转换为华氏温度请按1\n华氏温度转换为摄氏温度请按2\n')) if a=='1': c=float(input('请输入摄氏温度:')) f=c*9/5+32 print('摄氏{:.2f}的华氏为{:.2f}'.format(c,f)) else: f=floa 阅读全文

posted @ 2018-04-30 21:50 沈烨纯 阅读(89) 评论(0) 推荐(0)

2018年4月20日

理解数据类型与数学运算:求和、温度转换

摘要: f=input('请输入华氏温度') c=5/9*(float(f)-32) print('{}摄氏温度转换为华氏温度是{}'.format(f,c)) >>> a=input('请输入一个数') 请输入一个数5 >>> print(a) 5 >>> type(a) >>> int(a)+6 11 a=input('请输入一个摄氏温度') sum2=int(a)*9/5+32 pr... 阅读全文

posted @ 2018-04-20 10:58 沈烨纯 阅读(107) 评论(0) 推荐(0)

2018年4月18日

输入、输出与Mad Libs 游戏

摘要: name1=input('请输入一个名字') name2=input('请输入一个昵称') print('由于{}今天没有洗头,正信家的金毛{}被熏得离家出走了。'.format(name1,name2)) name=input('请输入你的名字') print('你好,{}吃饭了吗?'.format(name)) 阅读全文

posted @ 2018-04-18 20:49 沈烨纯 阅读(100) 评论(0) 推荐(0)

导航