会员
周边
捐助
新闻
博问
闪存
赞助商
所有博客
当前博客
我的博客
我的园子
账号设置
简洁模式
...
退出登录
注册
登录
周天凯
博客园
首页
新随笔
联系
订阅
管理
2018年6月14日
递归,汉诺塔游戏
摘要: 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(5, 'A', 'B', '
阅读全文
posted @ 2018-06-14 17:28 周天凯
阅读(128)
评论(0)
推荐(0)
编辑
2018年6月8日
列表、元组、字典、集合的定义、操作与综合练习
摘要: l = ['Michael', 'Bob', 'Tracy'] l.append('Bob') l.pop() print(1) t = ('Michael', 'Bob', 'Tracy') scores = [95, 70, 60] d = {'Michael': 95, 'Bob': 70,
阅读全文
posted @ 2018-06-08 18:28 周天凯
阅读(148)
评论(0)
推荐(0)
编辑
2018年5月30日
文件操作
摘要: fr = open('letter.txt',mode='r',encoding='utf-8') plaincode = fr.read() print('明文:'+ plaincode) print('密文',end='') for c in plaincode: print(chr(ord(c)+3),end='') turtle.speed(10) colors = ['...
阅读全文
posted @ 2018-05-30 21:20 周天凯
阅读(94)
评论(0)
推荐(0)
编辑
2018年5月23日
字符串操作
摘要: id='440902199706280054' area=id[0:8] 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)) prin...
阅读全文
posted @ 2018-05-23 20:58 周天凯
阅读(139)
评论(0)
推荐(0)
编辑
2018年5月16日
函数定义与使用
摘要: stuNum='201709090038' print('年级:'+stuNum[0:4]) print('专业:'+stuNum[4:9]) print('序号:'+stuNum[-3:]) IDNo='440902199706280054' print('性别是:'+IDNo[-2]) print('市区是'+IDNo[0:6]) print('生日是'+IDNo[6:13]) ...
阅读全文
posted @ 2018-05-16 21:20 周天凯
阅读(143)
评论(0)
推荐(0)
编辑
2018年5月9日
for循环:用turtle画一颗五角星
摘要: import turtle turtle. pencolor('blue') turtle. fillcolor('purple') turtle.begin_fill() while True: turtle. forward(100) turtle. right (150) if abs(turtle. position())<1: break t...
阅读全文
posted @ 2018-05-09 21:27 周天凯
阅读(161)
评论(0)
推荐(0)
编辑
程序执行流程/布尔类型与布尔:运算猜数字游戏;库的使用:turtle
摘要: mynumber=50 while True: guess=float(input('请输入一个数字')) if guess>mynumber: print('数字猜大了') elif guess<mynumber: print('数字猜小了') else: print('恭喜你猜对了') break...
阅读全文
posted @ 2018-05-09 19:12 周天凯
阅读(91)
评论(0)
推荐(0)
编辑
2018年4月25日
理解数据类型与数学运算:求和、温度转换2
摘要: c= input('请输入摄氏温度') f= float(c)*9/5+32 print('{}摄氏温度转为华氏温度{}'.format(f,c))
阅读全文
posted @ 2018-04-25 21:36 周天凯
阅读(109)
评论(0)
推荐(0)
编辑