摘要: 冒泡排序:就是将列表里的混乱的整形或其他进行有效的排序。test1: num=list('2574') n=len(num) print(num) for i in range(0,n): for j in range(i+1,n): if num[i]>num[j]: #a>b c=num[j] 阅读全文
posted @ 2018-03-28 17:37 Leonardo-li 阅读(365) 评论(0) 推荐(0)
摘要: 要求:通过定义一个列表,来插寻你输入的第N次的整形是多少。spam=[] n=int(input('输入多少次')) for i in range(0,n): spam.append(input('请输入第 '+ str(i+1)+ '次')) print('确认你的内容:') s=input() 阅读全文
posted @ 2018-03-28 17:32 Leonardo-li 阅读(200) 评论(0) 推荐(0)
摘要: 元素列表:1在列表最后一位添加元素>>> number=[1,2,3,4,5]>>> number.append(6)>>> print(number)[1, 2, 3, 4, 5, 6]>>> number[1, 2, 3, 4, 5, 6]>>> number.extend([7,8,9])>> 阅读全文
posted @ 2018-03-28 17:22 Leonardo-li 阅读(329) 评论(0) 推荐(0)
摘要: 1.random模块介绍通过模块参数的调用,可以随机生成不同的整形,浮点型,字符等 2.random参数的解释:随机整数random.randint(0,99)随机偶数random.randrange(0,101,2)随机浮点数random.random()/random.uniform(1,10) 阅读全文
posted @ 2018-03-28 17:16 Leonardo-li 阅读(301) 评论(0) 推荐(0)
摘要: def自定义函数: 1,自定义函数相当于局部变量,用了就没有了 def chengfa(i,j): print('你输入的乘法结果是:' + str(j*i)) return(j*i) chengfa(5,6) 执行的结果: 你输入的乘法结果是:30 Out[129]:30 def haha(): 阅读全文
posted @ 2018-03-26 17:11 Leonardo-li 阅读(5396) 评论(0) 推荐(0)
摘要: for循环:1,基础训练 方法一 例1 for i in (1,2,3,4,5,6,7,8,9,0): print('lpc') print(i) 元素列表: (1,2,3,4,5,6,7,8,9,0): for循环会对应匹配列表里每一个值,直到讲所有值循环完成结束 方法二 例1 for i in 阅读全文
posted @ 2018-03-26 17:01 Leonardo-li 阅读(1116) 评论(0) 推荐(0)
摘要: 1 import random 2 import pygame 3 import sys 4 from pygame.locals import * 5 6 Snakespeed = 17 7 Window_Width = 800 8 Window_Height = 500 9 Cell_Size 阅读全文
posted @ 2018-03-23 16:00 Leonardo-li 阅读(829) 评论(0) 推荐(0)
摘要: while True: print('who are you?') name=input() if name !='student': continue print('hello ' + name) print('请形容一下他,如,niu') r=input() if r=='niu': break 阅读全文
posted @ 2018-03-23 15:54 Leonardo-li 阅读(211) 评论(0) 推荐(0)
摘要: while True: print('请输入“thinks”') spam=input() if spam=='thinks': break print('yes it is!') break: 跳出真个循环语句并结束循环 阅读全文
posted @ 2018-03-23 15:51 Leonardo-li 阅读(250) 评论(0) 推荐(0)
摘要: 1.编写一个判断(if)两次输入密码是否一致的python代码文件 print('请输入密码——') passwd=input() print('再次输入密码——') passwd1=input() if passwd !=passwd1: print('密码不正确,请重新输入——') passwd 阅读全文
posted @ 2018-03-23 15:46 Leonardo-li 阅读(586) 评论(0) 推荐(0)