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

Who says straight men cant confess? Valentines day teaches you to send love in Python code

編輯:Python

It's today 214 Valentine's Day , Love a person with the same intention , But the ways can vary , As migrant workers in the new era, yard farmers , How can you lose ? Today I'll teach you to use Python Realization “ love ” The effect of , Fancy expression “ I love you! ”!

Easy to operate , Come on, try it :

Code implementation 1:

from turtle import *
def curvemove(): # This function is to draw the curve above love  for i in range(200): right(1) fd(1)
pensize(2) # Adjust the brush thickness speed(5) # Adjust brush speed color('red', 'red') # Brush color and fill color begin_fill() # Start filling left(140)fd(111.65)curvemove() # Call function left(120)curvemove() # Call function fd(111.65)end_fill() # End of filling hideturtle() # Hide the brush done()

Code implementation 2:

import turtle
# Draw a heart-shaped arc def hart_arc(): for i in range(200): turtle.right(1) turtle.forward(2)
def move_pen_position(x, y): turtle.hideturtle() # Hide the brush ( First ) turtle.up() # write  turtle.goto(x, y) # Move the brush to the specified starting coordinates ( The center is the window 0,0) turtle.down() # Write  turtle.showturtle() # Show paintbrush 
# initialization turtle.setup(width=800, height=500) # window ( canvas ) size turtle.color('red', 'pink') # Brush color turtle.pensize(3) # Brush thickness turtle.speed(1) # Describe speed # Initialize the brush start coordinates move_pen_position(x=0, y=-180) # Move the brush position turtle.left(140) # Rotate to the left 140 degree turtle.begin_fill() # Mark background fill position # Draw a heart line ( lower left )turtle.forward(224) # Move the brush forward , The length is 224# Draw the arc of love hart_arc() # Left arc turtle.left(120) # Adjust the brush angle hart_arc() # Right arc # Draw a heart line ( Lower right )turtle.forward(224)turtle.end_fill() # Mark background fill end position # Click on the window to close the program window = turtle.Screen()window.exitonclick()

The following is the supporting information , For doing 【 software test 】 For our friends, it should be the most comprehensive and complete war preparation warehouse , This warehouse also accompanied me through the most difficult journey , I hope it can help you !

Last : It can be in the official account : Programmer Xiaohao  ! Get a free copy of 216 Page software testing engineer interview guide document information . And the corresponding video learning tutorial is free to share !, It includes basic knowledge 、Linux necessary 、Shell、 The principles of the Internet 、Mysql database 、 Special topic of bag capturing tools 、 Interface testing tool 、 Test advanced -Python Programming 、Web automated testing 、APP automated testing 、 Interface automation testing 、 Testing advanced continuous integration 、 Test architecture development test framework 、 Performance testing 、 Safety test, etc. .

If my blog helps you 、 If you like my blog content , please “ give the thumbs-up ” “ Comment on ” “ Collection ” One button, three links ! Friends who like software testing , You can join our testing technology exchange group :779450660 There are various software testing resources and technical discussions )


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