Python学习
childoge
这个作者很懒,什么都没留下…
展开
-
打印范围内的斐波那契数
打印范围内的斐波那契数def fib(): a = 1 b = 1 c = a + b while True: a = b b = c c = a + b yield cfor fn in fib(): if fn < 1000: print (fn) els...原创 2019-12-30 13:30:42 · 166 阅读 · 0 评论 -
海龟作图,沙盒弹珠(小球)碰撞演示
海龟作图,沙盒弹珠(小球)碰撞演示import turtlefrom random import randintimport timew,h = 500,400screen = turtle.Screen()screen.delay(0)screen.bgcolor('black')screen.setup (w,h)screen.title("沙盒弹珠碰撞演示,作者:chi...原创 2019-12-30 12:04:39 · 586 阅读 · 0 评论 -
Python,海龟作图,闪避球小游戏
闪避球游戏闪避球游戏,Python海龟作图游戏。规则:吃三角可以加5分,被球碰到游戏结束,前后左右按键可以移动方块,100分可以赢。import turtleimport randomimport timew,h = 500,400screen = turtle.Screen()screen.delay(0)screen.bgcolor('black')screen.set...原创 2019-12-29 07:19:49 · 2548 阅读 · 0 评论 -
Python二叉树+随机颜色+心型树叶代码
Python二叉树+随机颜色+心型树叶代码import turtleimport randomt = turtle.Turtle()w = turtle.Screen()t.speed(10)def tree(branchlen,t): if branchlen > 5: t.pensize(branchlen//10+1) t....原创 2019-12-29 00:57:47 · 485 阅读 · 0 评论 -
Python 水仙花数代码,并计算耗时
Python 水仙花数代码,并计算耗时import timedef shuixianhua(a): sum = 0 for i in range(0,int(len(a))): sum += int(a[int(str(i))])**int(len(a)) if int(sum) == int(a): print('%d是水仙花数'...原创 2019-12-29 00:18:43 · 596 阅读 · 0 评论