程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Send you a complete set of exclusive Python code for Valentines Day (robbery)

編輯:Python

Today is Valentine's Day , Give you a set of exclusive Python Code , It seems a little late ... But it doesn't matter , You can keep it for next time

Rose

Part of the code is implemented as follows :

#  petals 1
turtle.left(150)
turtle.circle(-90, 70)
turtle.left(20)
turtle.circle(75, 105)
turtle.setheading(60)
turtle.circle(80, 98)
turtle.circle(-90, 40)
#  petals 2
turtle.left(180)
turtle.circle(90, 40)
turtle.circle(-80, 98)
turtle.setheading(-83)
#  leaf 1
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)

effect :

Love tree

Part of the code is implemented as follows :

#  Draw love
def love(x, y):
    lv = turtle.Turtle()
    lv.hideturtle()
    lv.up()
    #  location
    lv.goto(x, y)
    #  Draw an arc
    def curvemove():
        for i in range(20):
            lv.right(10)
            lv.forward(2)
    lv.color('red', 'pink')
    lv.speed(10000000)
    lv.pensize(1)
    lv.down()
    lv.begin_fill()
    lv.left(140)
    lv.forward(22)
    curvemove()
    lv.left(120)
    curvemove()
    lv.forward(22)
    #  Reset after drawing
    lv.left(140)
    lv.end_fill()

effect :

Cupid

Part of the code is implemented as follows :

t.color('red','pink')
t.begin_fill()
t.width(5)
t.left(135)
t.fd(100)
t.right(180)
t.circle(50,-180)
t.left(90)
t.circle(50,-180)
t.right(180)
t.fd(100)
t.pu()
t.goto(50,-30)
t.pd()
t.right(90)
t.fd(100)
t.right(180)
t.circle(50,-180)
t.left(90)
t.circle(50,-180)
t.right(180)
t.fd(100)
t.end_fill()
t.hideturtle()
t.pu()
t.goto(250,-70)
t.pd()

effect :

Colorful balloon

Part of the code is implemented as follows :

#  balloon
balloons = []
#  Color
color_option = ["red", "blue", "green", "purple", "pink", "yellow", "orange"]
#  Balloon size
size = 50
#  Balloon line
def line(x, y, a, b, line_width=1, color_name="black"):
    up()
    goto(x, y)
    down()
    color(color_name)
    width(line_width)
    goto(a, b)
def distance(x, y, a, b):
    #  Judge the distance between the mouse click position and the balloon coordinates
    return ((a - x) ** 2 + (b - y) ** 2) ** 0.5
def tap(x, y):
    for i in range(len(balloons)):
        #  Determine whether to click one of the balloons in the queue
        if distance(x, y, balloons[i][0], balloons[i][1]) < (size / 2):
            #  Delete balloon
            balloons.pop(i)
            return

effect :

All the codes have been packed and sorted out , Small buddy can be in official account. Python waiter The background to reply 20220214 obtain ~

Looking back :

  • Python Learning manual

  • Pandas Learning gift bag

  • 100+ Python Reptile project

  • Python Introduction to data analysis

  • 100  Avenue  Python  Classic exercises

  • 70 individual Python Classic practical hand training project

  • 20 Zhang HD data analysis (Python) Full knowledge map

  • 14 Zhang Python Data analysis of quick look-up table & visualization & machine learning


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved