时间:2022-10-25 09:31:55 | 栏目:Python代码 | 点击:次
python用turtle画简单图案比较方便,大一学python的turtle模块时,记得要画各种图案,如国旗,桃心等等图案,期末课程设计时有可能还会遇到画54张扑克牌,当初室友就被迫选了这道题。
有时候程序猿遇到自己悄悄喜欢的女生又不敢表白,那么就用turtle来实现表白吧!!!!!!!
import turtle import time def LittleHeart(): for i in range(200): turtle.right(1) turtle.forward(2) isLove=input('你会一直爱她吗?(Y or N)\n') run =1 while(run): if isLove=="Y": me="" love="" if love=='': love=' 草莓 I love you' turtle.setup(width=900, height=500) turtle.color('red','red') turtle.pensize(3) turtle.speed(50) turtle.up() turtle.hideturtle() turtle.goto(0,-180) turtle.showturtle() turtle.down() turtle.speed(5) turtle.begin_fill() turtle.left(140) turtle.forward(224) LittleHeart() turtle.left(120) LittleHeart() turtle.forward(224) turtle.end_fill() turtle.pensize(5) turtle.up() turtle.hideturtle() turtle.goto(0,0) turtle.showturtle() turtle.color('#CD5C5C','blue') turtle.write(love,font=('gungsuh',30,),align="center") turtle.up() turtle.hideturtle() if me !='': turtle.color('yellow', 'red') time.sleep(2) turtle.goto(180,-180) turtle.showturtle() turtle.write(me, font=(20,), align="center", move=True) window=turtle.Screen() window.exitonclick() run =0 else: print("活该单身一辈子") print("!!!!!!!!!再给你一次机会!!!!!!!!") isLove=input('你会一直爱她吗?(Y or N)\n') continue
运行结果:
print('\n'.join([''.join([('I'[(x-y) % len('I')]if ((x*0.05)**2+(y*0.1)**2-1)**3-(x*0.05)**2*(y*0.1)**3 <= 0 else ' ')for x in range(-30, 30)])for y in range(30, -30, -1)]))
print('\n'.join([''.join([('Love'[(x-y) % len('Love')]if ((x*0.05)**2+(y*0.1)**2-1)**3-(x*0.05)**2*(y*0.1)**3 <= 0 else ' ')for x in range(-30, 30)])for y in range(30, -30, -1)]))
print('\n'.join([''.join([('You'[(x-y) % len('You')]if ((x*0.05)**2+(y*0.1)**2-1)**3-(x*0.05)**2*(y*0.1)**3 <= 0 else ' ')for x in range(-30, 30)])for y in range(30, -30, -1)]))
print('\n'.join([''.join([('Raven'[(x-y) % len('Raven')]if ((x*0.05)**2+(y*0.1)**2-1)**3-(x*0.05)**2*(y*0.1)**3 <= 0 else ' ')for x in range(-30, 30)])for y in range(30, -30, -1)]))