hanoi

摘要: 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:28 八达岭 阅读(150) 评论(0) 推荐(0) 编辑

列表、元组、字典、集合

摘要: 列表是任何数据类型,是可变的、有序的。字典是不可变序列才能做键,是可变的、无序的。元组是任何数据类型,是不可变的、有序的。 阅读全文
posted @ 2018-06-06 21:43 八达岭 阅读(119) 评论(0) 推荐(0) 编辑

画图

摘要: import turtlecolors=['yellow','red','black','blue','purple','orange']turtle.speed(10)for i in range(100): turtle.pencolor(colors[i%6]) turtle.forward( 阅读全文
posted @ 2018-05-30 21:22 八达岭 阅读(107) 评论(0) 推荐(0) 编辑

文件操作

摘要: fr = open('letter.txt',mode='r',encoding='utf-8')plaincode = fr.read()fr.closefw = open('c_letter.txt',mode='a',encoding='utf-8')for c in plaincode: f 阅读全文
posted @ 2018-05-30 20:50 八达岭 阅读(85) 评论(0) 推荐(0) 编辑

凯撒密码2

摘要: fr = open('letter.txt',mode='r',encoding='utf-8')plaincode = fr.read()print('明文:' + plaincode)print('密文:',end='')for c in plaincode: print(chr(ord(c)+ 阅读全文
posted @ 2018-05-30 20:33 八达岭 阅读(434) 评论(0) 推荐(0) 编辑

凯撒密码

摘要: s = input('文明:')for c in s: print(chr(ord(c)+3),end='') s = input('密文:')for c in s: print(chr(ord(c)-3),end='') 阅读全文
posted @ 2018-05-23 20:48 八达岭 阅读(160) 评论(0) 推荐(0) 编辑

星座

摘要: for i in range(12): print(9800+i,chr(9800+i)) 阅读全文
posted @ 2018-05-23 20:27 八达岭 阅读(179) 评论(0) 推荐(0) 编辑

通过身份证号的性别位奇偶数来判定“男、女”

摘要: id = '440683199901013256'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') 阅读全文
posted @ 2018-05-23 20:26 八达岭 阅读(562) 评论(0) 推荐(0) 编辑

通过身份证号的性别位奇偶数来判定是“男”还是“女”

摘要: id = '440683199901013256'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') 阅读全文
posted @ 2018-05-23 20:24 八达岭 阅读(663) 评论(0) 推荐(0) 编辑

字符串

摘要: stuNum = '201709080025' print('年级是:'+stuNum[0:4]) print('专业编号是:'+stuNum[4:8]) print('班级是:'+stuNum[8:9]) print('序号:'+stuNum[-3:]) id='44030219990101369 阅读全文
posted @ 2018-05-16 21:38 八达岭 阅读(105) 评论(0) 推荐(0) 编辑