Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to make a Love Collection by Python

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article will explain in detail how to make a love collection by Python. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.

Text

First, love confession: be my girlfriend, OK, no, I'll think of a way.

1) effect display

2) attached main program

T=turtle.pen () t=turtlet.up () t.goto (0150) t.down () t.color ('pink') t.begin_fill () t.fillcolor (' pink') t.speed (1) t.left (45) t.forward (150) t.right (45) t.forward (45) t.forward (45) t.right (45) t.forward (45) t.right (45) t.forward (250+math.sqrt (2) * t.right (90) t.speed (2) t.forward (250+100*math.sqrt (2)) t.right (45) t.forward (45) t.right (45) t.forward (100) t.right (45) t.forward (45) t.right (45) t.forward (150) t.end_fill () t.goto (- 10 t.goto 0) t.pencolor ('white') # Lt.pensize (10) t.goto (- 50) t.goto (- 50) t.up () # It .goto (- 100pr 0) t.down () t.goto (- 160L0) t.goto (- 130L0) t.goto (- 130lle 80) t.goto (- 160pr 80) t.goto (- 100pr 80) t.up () # Ot.goto (10pr 25) t.down () t.right (45) t.circle (25) Extent=180) t.goto (60, 55) t.circle (25) t.up () t.goto () t.down () t.goto (100) t.goto (125) t.goto (180) t.down () t.goto (140) t.goto (140) t.goto (180) t.up () t.goto (180) 40) t.down () t.goto (140) # Ut.up () t.goto (- 40) -30) t.down () t.goto (- 40 mahjay 80) t.circle (40 meme Extenture 180) t.goto (40 qime 30) t.hideturtle () a=input ()

Second, the confession of love: There are two wishes: you are by your side, by your side

1) effect display

2) attached main program

Pen = turtle.Turtle () pen.hideturtle () pen.fillcolor ('pink') pen.begin_fill () # set the starting directionpen.left (110) # draw the left bottom partwhile pen.heading ()

< 140: # rotate & forward pen.left(1) pen.forward(2)# move uppen.forward(90)# draw the left upper partwhile pen.xcor() < 0: pen.right(0.8) pen.forward(1)# go back to the starting point, and do the right part as a mirrorpen.up()pen.goto(0, 0)pen.down()# set the directionpen.setheading(70)# draw the right bottom partwhile pen.heading() >

40: # Defining step by step curve motion pen.right (1) pen.forward (2) # move uppen.forward (90) # draw the right upper partwhile pen.xcor () > 0: print (pen.xcor ()) pen.left (0.8) pen.forward (1) # Ending the filling of the colorpen.end_fill ()

Third, the confession of love: the first acquaintance is like the return of an old friend. The bright moon at the end of the world is new, and I miss each other most at dusk.

1) effect display

2) attached main program

Import turtle as tdef heart (xQuery yjinz): # draw love t.pensize (2) t.pencolor ("black") if z = 1: t.fillcolor ("red") elif z = 0: t.fillcolor ("pink") t.begin_fill () # left half t.penup () t.goto (x Y) t.pendown () t.circle (50180) t.circle (180Magn37) t.left (46) # right half t.circle (180Co37) t.circle (50182) t.end_fill () def arrow1 (xPowery): t.pensize (5) t.pencolor ("black") t.fillcolor ("brown") t.penup () t.goto (x Y) t.pendown () t.setheading (210) t.forward (150) t.begin_fill () t.left (30) t.forward (20) t.right (50) t.forward (50) t.right (20) t.forward (20) t.left (120) t.forward (20) t.right (50) t.forward (50) t.right ( 30) t.forward (20) t.end_fill () def arrow2 (x Y): t.pensize (5) t.pencolor ("black") t.fillcolor ("brown") t.penup () t.goto (x Y) t.pendown () t.begin_fill () t.setheading (30) t.forward (100) t.left (90) t.forward (8) t.right (120th) t.forward (16) t.right (16) t.forward (16) t.right (120th) t.forward (8) t.end_fill () def main (): t.setheading (90) heart (50130) 0) t.setheading (120,120) heart (0,100,1) arrow1 (- 20,60) arrow2 (100,130) t.hideturtle () t.exitonclick () on "how to make a collection of love expressed by Python" this article ends here. Hope that the above content can be helpful to you, so that you can learn more knowledge, if you think the article is good, please share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report