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 Qixi Festival's confession by Python

2025-04-08 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article mainly introduces how Python makes Qixi Festival's heart-to-heart confession, which is very detailed and has a certain reference value. Interested friends must finish reading it!

Basic parameters of Turtle

The power of python is that it has many powerful libraries, of which turtle is a module for interactive painting. It is also a secret magic weapon for many beginners to have fun learning python!

As an art idiot, it may be difficult to draw a picture, but with python's turtle library, you can paint with only a few lines of code.

Turtle is a library that comes with python, so you can call it directly.

From turtle import *

Draw pictures of sea turtles

However, in order to save work and make it easier to read the code, we can create some functions so that we don't have to write a lot of basic code many times.

Def heart (x, y, size): go_to (x, y) left (150) begin_fill () forward (51*size) ring

Successfully drew a heart and filled it with color.

The rest of us can use straight lines and curves to draw the villain's head, arms and body in turn.

Def people (): # head color ('black') go_to (- 228,72) pensize (3) left (350,1,0.8, "right") # arm left (150) forward (70) left (90) forward (10) ring (200,0.1,0.9) 'right') forward (10) left (90) forward (20) ring (200,0.1,0.9,' right') forward (10) left (90) ring (200,0.2,0.9, 'right') left (100) forward (80)

Of course, in addition to adding a heart, you can also add some text. If you want to customize the text, just change the text 520 in the parameters directly.

# add words go_to (- 39, 69) write ("520", font= ("boldface", 30, "normal"))

Final result

The above is all the contents of the article "how to make Qixi Festival confession by Python". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

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