代码改变世界

期末综合大作业:词频统计

2018-06-20 21:37 by lulululululululu, 200 阅读, 0 推荐, 收藏, 编辑
摘要:#1. theFile = open('the.txt',mode="r",encoding='utf-8') theText = theFile.read() theFile.close() print(theText) #2. replaceList = [',','.',"'",'\n'] for c in replaceList: theText = theText.repl... 阅读全文

递归,汉诺塔游戏

2018-06-13 20:50 by lulululululululu, 145 阅读, 0 推荐, 收藏, 编辑
摘要: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') 阅读全文

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

2018-06-06 21:26 by lulululululululu, 121 阅读, 0 推荐, 收藏, 编辑
摘要:l = ['Michael','Bob','Tracy'] l.append('Bob') l.pop() print(1) t = ('Michael','Bob','Tracy') scores = [85,65,55] d = {'Michael':85,'Bob':65,'Tracy':55 阅读全文

文件操作

2018-05-30 20:50 by lulululululululu, 201 阅读, 0 推荐, 收藏, 编辑
摘要:classmates = ['Michael','Bob','Tracy'] classmates.append('Rose') classmates.insert(1,'Jack') classmates.pop() classmates.pop(0) classmates[0] = 'Tom' print(classmates) import turtle turtle.spee... 阅读全文

字符串操作

2018-05-23 21:02 by lulululululululu, 180 阅读, 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='') for i in range(12): print(9800+i,chr(9800+i)) id = '6501021999... 阅读全文

函数定义与使用 字符串类型

2018-05-16 20:32 by lulululululululu, 320 阅读, 0 推荐, 收藏, 编辑
摘要:stuNum = '201709080051' print('年级是:'+stuNum[0:4]) print('专业编号是:'+stuNum[4:9]) print('序号是:'+stuNum[-3:]) IDNo = '650102199908240726' print('性别是;'+IDNo[-2]) import turtle turtle.bgcolor("red") t... 阅读全文

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

2018-05-16 20:00 by lulululululululu, 809 阅读, 0 推荐, 收藏, 编辑
摘要:import turtle turtle.setup(600,400,0,0) turtle.bgcolor('red') turtle.pencolor('yellow') turtle.fillcolor('yellow') turtle.penup() turtle.goto(-250,100 阅读全文

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

2018-05-02 21:37 by lulululululululu, 216 阅读, 0 推荐, 收藏, 编辑
摘要:myNumber = 7 while True: guess = int(input('猜猜这个数字是什么')) if guess > myNumber: input('这个数字大了') elif guess < myNumber: input('这个数字小了') else: print('猜对了') ... 阅读全文

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

2018-04-25 21:24 by lulululululululu, 277 阅读, 0 推荐, 收藏, 编辑
摘要: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 = float(input('请输入华氏温度:')) ... 阅读全文

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

2018-04-25 21:02 by lulululululululu, 140 阅读, 0 推荐, 收藏, 编辑
摘要: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 阅读全文