2018年6月20日

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

摘要: #1, lFile = open('l.txt','r') lTest = lFile.read() lFile.close() print(lTest) #2, print(lTest.replace(',',' ')) print(lTest.replace("'",' ')) print(lT 阅读全文

posted @ 2018-06-20 21:27 刘婵 阅读(74) 评论(0) 推荐(0) 编辑

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 21:19 刘婵 阅读(108) 评论(0) 推荐(0) 编辑

2018年6月6日

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

摘要: l = ['Lisa','Jack','Alisa'] l.append('Bob') l.pop() print(1) t = ('Lisa','Jack','Alisa') scores = [80,60,50] d = {'Lisa':80,'Jack':60,'Alisa':50} d['B 阅读全文

posted @ 2018-06-06 21:32 刘婵 阅读(94) 评论(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='') fr = open('ccc.txt',mod... 阅读全文

posted @ 2018-05-30 21:23 刘婵 阅读(94) 评论(0) 推荐(0) 编辑

2018年5月23日

字符串操作

摘要: id= '36072319990616004X' area = id[0:6] birthday = id[6:16] sex = id[-2] print(area,birthday,sex) if (int(sex) % 2 == 0): print('girl') else: print('boy') for i in range(12): print(9... 阅读全文

posted @ 2018-05-23 21:12 刘婵 阅读(96) 评论(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.goto(x,y) turtle.pendown() ... 阅读全文

posted @ 2018-05-16 20:36 刘婵 阅读(90) 评论(0) 推荐(0) 编辑

2018年5月9日

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

摘要: import turtle turtle.bgcolor('red') turtle.pencolor('yellow') turtle.fillcolor('yellow') turtle.begin_fill() for i in range(5): turtle.forward(100) tu 阅读全文

posted @ 2018-05-09 20:56 刘婵 阅读(130) 评论(0) 推荐(0) 编辑

2018年5月2日

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

摘要: myNumber = 13 while True: guess = int(input('请输入一个数量:')) if guess > myNumber: print('输入的数量过大') elif guess >> import turtle >>> turtle.circle(50,steps=6) >>> turtle.color('yellow'... 阅读全文

posted @ 2018-05-02 21:38 刘婵 阅读(123) 评论(0) 推荐(0) 编辑

2018年4月25日

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

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

posted @ 2018-04-25 21:30 刘婵 阅读(105) 评论(0) 推荐(0) 编辑

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

摘要: 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: 阅读全文

posted @ 2018-04-25 21:12 刘婵 阅读(76) 评论(0) 推荐(0) 编辑

导航