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 realize the confession Code with Python

2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

In this article Xiaobian for you to introduce in detail "how to use Python to achieve confession code", the content is detailed, the steps are clear, the details are handled properly, I hope this "how to use Python to achieve confession code" article can help you solve your doubts, the following follow the editor's ideas slowly in-depth, together to learn new knowledge.

Romantic roses

Implementation code:

From turtle import * import time setup (1000, 800, 800, 0 0) speed (0) penup () seth (90) fd (340) seth (0) pendown () speed (5) begin_fill () fillcolor ('red') circle (50 for i in range 30) for i in range (10): fd (1) left (10) circle (40) for i in range (6): fd (1) left (3) circle (80) for i in range (20): fd (0.5) left (5) circle (80) 45) for i in Range (10): fd (2) left (1) circle (80pr 25) for i in range (20): fd (1) left (4) circle (50) time.sleep (0.1) circle (120,055) speed (0) seth (- 90) fd (70) right (20) fd (20) left (140) circle (140Magne90) left (30) circle (160100) left (25) penup () right (150) circle (40L80) pendown () left Fd (60) penup () left (180) fd (60) pendown () end_fill () right (20) circle (- 50) speed (1) fd (75) speed (0) circle (90110) penup () left (162e) fd (185C) left (170C) pendown () circle (200m 10) circle (100m 40) circle (- 52115) left (20) circle (100m 20) circle (300J 20) speed (1) fd (250T) penup (speed) left Right (80) circle (200jing5) pendown () left (60) begin_fill () fillcolor ('green') circle (- 80100) right (90) fd (10) left (20) circle (- 63127) end_fill () left (50) fd (20) left (180) pendown () circle (25) penup () right () fd (180) right (40) begin_fill () fillcolor (' green') circle (- 100cent80) right (150) fd (10) ) left (60) circle (- 80 Magazine 98) end_fill () penup () left (60) fd (13) left (180) pendown () speed (1) circle (- 200 Magne23) exitonclick ()

What? Only roses are too monotonous? Will it be enough to give you a few more hearts?

Romantic roses and love

Implementation code:

Import turtleimport timeimport random # Love function def yellowheart (x, y, liftx): turtle.pensize (3) turtle.speed (10) turtle.color ("red", "red") turtle.up () turtle.goto (x, y) turtle.down () turtle.begin_fill () turtle.left (liftx) turtle.fd (80) turtle.circle (- 40180) turtle.left (90) turtle.circle (- 40) Turtle.left (0) turtle.fd (80) turtle.end_fill () def rose (): turtle.speed (0) # Speed of brush movement # turtle.tracer (False) # set initial position turtle.penup () # lift brush turtle.left (90) # turn brush 90 degrees counterclockwise turtle.fd (200) turtle.pendown () # put down brush Move the brush to start painting turtle.right (90) # set the brush size turtle.pensize (2) # stamen turtle.fillcolor ("red") # fill color turtle.begin_fill () # start filling turtle.circle (10,180) turtle.circle (25,110) turtle.left (50) turtle.circle (60,45) turtle.circle (20 Turtle.right (24) turtle.fd (30) turtle.left (10) turtle.circle (30,110) turtle.fd (20) turtle.left (40) turtle.circle (90,70) turtle.circle (30,150) turtle.right (30) turtle.fd (15) turtle.circle (80 90) turtle.left (15) turtle.fd (45) turtle.right (165,165) turtle.fd (20) turtle.left (155,80) turtle.left (50) turtle.circle (150,90) turtle.end_fill () # end filling # right petal turtle.left (150) turtle.circle (- 90,70) turtle.left (20) turtle.circle (75 Turtle.setheading (60) turtle.circle (80,98) turtle.circle (- 90,40) # left petal turtle.left (180) turtle.circle (90,40) turtle.circle (- 80 98) turtle.setheading (- 83) # left leaf turtle.fd (30) turtle.left (90) turtle.fd (25) turtle.left (45) turtle.fillcolor ("green") turtle.begin_fill () turtle.circle (- 80,90) turtle.right (90) turtle.circle (- 80) 90) turtle.end_fill () turtle.right (135) turtle.fd (60) turtle.left (180) turtle.fd (85) turtle.left (90) turtle.fd (80) # right leaf turtle.right (90) turtle.right (45) turtle.fillcolor ("green") turtle.begin_fill () turtle.circle (80,90) turtle.left (90) turtle.circle (80) 90) turtle.end_fill () turtle.left (135) turtle.fd (60) turtle.left (180) turtle.fd (60) turtle.right (90) turtle.circle (200,50) # draw a circle 200 is the radius 50 is Radian time.sleep (1) # turtle.tracer (False) # turtle.pensize (3) # turtle.speed (0) turtle.color ("red", "red") turtle.up () turtle.goto (- 230,50) turtle.down () turtle.begin_fill () turtle.left (80) turtle.circle (- 40180) turtle.left (90) turtle.circle (- 40) Turtle.left (0) turtle.fd (80) turtle.end_fill () time.sleep (1) # turtle.tracer (False) # turtle.pensize (3) # turtle.speed (0) turtle.color ("red", "red") turtle.up () turtle.goto -80) turtle.down () turtle.begin_fill () turtle.left (- 30) turtle.fd (80) turtle.circle (- 40180) turtle.left (90) turtle.circle (- 40) Turtle.left (0) turtle.fd (80) turtle.end_fill () time.sleep (1) # turtle.tracer (False) # turtle.pensize (3) # turtle.speed (0) turtle.color ("red", "red") turtle.up () turtle.goto Turtle.down () turtle.begin_fill () turtle.left (- 80) turtle.fd (80) turtle.circle (- 40,180) turtle.left (90) turtle.circle (- 40) Turtle.left (0) turtle.fd (80) turtle.end_fill () time.sleep (1) # turtle.tracer (False) # turtle.pensize (3) # turtle.speed (0) turtle.color ("red", "red") turtle.up () turtle.goto Turtle.down () turtle.begin_fill () turtle.left (- 90) turtle.fd (80) turtle.circle (- 40,180) turtle.left (90) turtle.circle (- 40) Turtle.left (0) turtle.fd (80) turtle.end_fill () time.sleep (1) # turtle.tracer (False) # turtle.pensize (3) # turtle.speed (0) turtle.color ("red", "red") turtle.up () turtle.goto 50) turtle.down () turtle.begin_fill () turtle.left (90) turtle.fd (80) turtle.circle (- 40,180) turtle.left (90) turtle.circle (- 40180) turtle.left (0) turtle.fd (80) turtle.end_fill () def figure1 (): turtle.reset () turtle.tracer (False) rose () yellowheart (- 230,50 # left # time.sleep (2) def figure2 (): # turtle.reset () turtle.tracer (False) rose () yellowheart (- 230,80,30) # left second # time.sleep (2) def figure3 (): turtle.reset () turtle.tracer (False) rose () yellowheart (- 130,180) -30) # left three # time.sleep (2) def figure4 (): turtle.reset () turtle.tracer (False) rose () yellowheart (200,50,90) # right one # ime.sleep (2) def figure5 (): turtle.reset () turtle.tracer (False) rose () yellowheart -90) # right second # time.sleep (2) if _ name__ = = "_ _ main__": rose () # figure1 () # # yellowheart (- 230,80,-30) # left second # do not allow automatic exit, put it on the last line of the program # otherwise it will automatically exit turtle.done () coding:utf- 83 after drawing, heart to heart

Implementation code:

From turtle import * from time import sleepdef go_to (x, y): up () goto (x Y) down () def small_Circle (size): # function to draw the small circle of the heart speed (10) for i in range: forward (size) right (0.786) def big_Circle (size): # function to draw the large circle of the heart speed (10) for i in range (150): forward (size) right Size): speed (10) forward (51 * size) def heart (x Y, size): go_to (x, y) left (150,150) begin_fill () line (size) big_Circle (size) small_Circle (size) left (120small_Circle (size) big_Circle (size) line (size) end_fill () def main (): pensize (2) color ('red',' pink') getscreen (). Tracer (1,0) heart (100,0) Go_to (80,70) write ("Sir", font= ("italics", 18, "normal") setheading (0) heart (- 80,100,1) go_to (- 110,15) write ("Miss", font= ("Arial", 20, "normal")) go_to (40,-80) write ("Nice to meet you!" , move=True, align= "left", font= ("arial", 22, "italic") done () main () 4. Pink tender love

Implementation code:

Coding=utf-8import turtleimport time def draw_circle (): for i in range (400): turtle.right (0.5) turtle.forward (1) def draw_love (): # turtle.color ('red','darkred') # turtle.pensize (1) turtle.pen (fillcolor= "pink", pencolor= "red", pensize=8) turtle.speed (2000) turtle.goto (0) 0) turtle.begin_fill () turtle.left (140,140) turtle.forward () turtle.left () draw_circle () turtle.forward () turtle.end_fill () turtle.write ("I Love you") time.sleep (2) turtle.up () turtle.goto (150,20) turtle.color ('black') turtle.write Even though I love you to the bone, I still treat you as before!' , font= ("Microsoft Acer", 18, "normal") time.sleep (2) def draw_abc (): turtle.fillcolor ("pink") turtle.pencolor ("red") turtle.pensize (10) turtle.speed (1) turtle.up () turtle.goto (0 -50) turtle.down () turtle.begin_fill () turtle.circle (45) turtle.end_fill () time.sleep (2) def word (): turtle.up () turtle.goto (- 100,200) turtle.color ("red") turtle.pensize (4) # turtle.down () turtle.write ('baby 5.20 Happy!' , font= ("official script", 18, "bold") time.sleep (10) draw_love () draw_abc () word () 5. Cupid pierced the heart with one button.

Program code:

Import turtle as tt.color ('red','pink') t.begin_fill, t.width, t.left, t.fd, t.right, t.circle, t.left, t.circle, t.right, t.fd, t.pu, t.goto, t.pd, t.right, t.fd, t.circle. -1800) t.left (90) t.circle (50mam Lashi 180) t.right (180) t.fd (100) t.end_fill () t.hideturtle () t.pu () t.goto (250) -70) t.pd () t.color ('black') t.width (5) t.left (70) t.fd (50) t.fd (- 50) t.left (70) t.fd (50) t.fd (- 50) t.left (145) t.fd (20) t.left (50) t.fd (50) t.fd (- 50) t.left (70) t.fd (50) t.fd (- 50) t.left 20) t.left (145i) t.fd (50) t.fd (- 50) t.left (70) t.fd (50) t.fd (- 50) t.left (145i) t.width (3) t.fd (220t.right (90) t.pu () t.fd (10) t.pd (90) t.circle (10180) t.circle (10) -90) t.right (90) t.fd (- 10) t.pu () t.fd (90) t.left (90) t.fd (10) t.left (90) t.pd () t.circle (10180) t.circle (10) -90) t.left (90) t.fd (100) t.begin_fill () t.left (30) t.fd (15) t.right (35) t.fd (50) t.right (50) t.fd (50) t.right (62) t.fd (25) t.end_fill () t.done () VI.

Implementation code:

# 2.14from turtle import * from time import sleep def go_to (x, y): up () goto (x, y) down () def head (x, y, r): go_to (x, y) speed (1) circle (r) leg (x, y) def leg (x, y): right (90) forward (180) right (30) forward (100) left (120) go_to (x Go_to (x, y-60) forward (100) left (60) forward (x, y-90) right (60) forward (60) right (60) forward (100) left (60) eye (x, y) def eye (x Y): go_to (x-50, y + 130) right (90) forward (50) go_to (x + 40) Y + 130) forward (50) left (90) def big_Circle (size): speed (20) for i in range (150): forward (size) right (0.3) def line (size): speed (1) forward (51 * size) def small_Circle (size): speed (10) for i in range (10): forward (size) right (0.786) def heart (x, y) Size): go_to (x, y) left (150) begin_fill () line (size) big_Circle (size) small_Circle (size) left (size) small_Circle (size) big_Circle (size) line (size) end_fill () def main (): pensize (2) color ('red',' pink') head (- 120,100,100) heart (250,- 80) 1) go_to (200,300) write ("To: for fairies with wisdom and beauty!" , move=True, align= "left", font= ("italics", 20, "normal") done () main () 7. Romantic dynamic cherry trees

Implementation code:

Import turtle as Timport randomimport time # painting the torso of cherry blossoms (60 branch t) def Tree (branch, t): time.sleep (0.0005) if branch > 3: if 8

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