2018年6月6日

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

摘要: l = ['Michael','Bob','Tracy'] l.append('Bob') l.pop() print(1) t = ('Michael','Bob','Tracy') scores = [95,75,85] d = {'Michael':95,'Bob':75,'Tracy':85} d['Bob'] = 82 d['Rose'] = 88 d.pop('Bob') p. 阅读全文

posted @ 2018-06-06 20:50 莫楚瑶 阅读(248) 评论(0) 推荐(0) 编辑

2018年5月30日

文件操作,列表实例NiceHexSpiral

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

posted @ 2018-05-30 20:51 莫楚瑶 阅读(155) 评论(0) 推荐(0) 编辑

2018年5月23日

字符串操作

摘要: stuNum = '201709080024' print('年级是:'+stuNum[0:4]) print('专业编号是:'+stuNum[4:9]) print('序号是:'+stuNum[-3:]) IDNo= '440609199802180026' print('省市是:'+IDNo[0:2]) print('生日是:'+IDNo[-8:-4]) print('性别是:'+ID... 阅读全文

posted @ 2018-05-23 19:55 莫楚瑶 阅读(114) 评论(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() def dra... 阅读全文

posted @ 2018-05-16 21:31 莫楚瑶 阅读(146) 评论(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) turtle.circle(25, 110) turtle.left... 阅读全文

posted @ 2018-05-09 20:54 莫楚瑶 阅读(1173) 评论(0) 推荐(0) 编辑

2018年5月2日

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

摘要: input ('let start') myNumber = 8 while True: guess = int(input()) if guess > myNumber: print('>') elif guess < myNumber: print('<') else: print('=') b... 阅读全文

posted @ 2018-05-02 21:49 莫楚瑶 阅读(188) 评论(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,f)) elif a==2: ... 阅读全文

posted @ 2018-04-25 21:42 莫楚瑶 阅读(208) 评论(0) 推荐(0) 编辑

2018年4月18日

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

摘要: a = input('请输入第一个数') b = input('请输入第二个数') sum2 = int(a) + int(b) print('两个数的和是: {}'.format(sum2)) a = input('请输入一个摄氏温度') sum2 =int(a) * 5/9 +32 print('转换的华氏温度是:{}'.format(sum2)) a = input('请... 阅读全文

posted @ 2018-04-18 21:43 莫楚瑶 阅读(114) 评论(0) 推荐(0) 编辑

输入、输出与Mad Libs 游戏

摘要: name1 = input('请输入一个名字:') name2 = input('再输入一个名字:') animal = input('请输入一种动物:') print ('我打开名为{}APP的时候,{}惊呆了,然后带上{},很快的逃走了'.format(name1,name2,animal)) 阅读全文

posted @ 2018-04-18 21:06 莫楚瑶 阅读(91) 评论(0) 推荐(0) 编辑

导航