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 write the sample code of Python to create the artifact of blessing in the year of the Tiger?

2025-02-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

Today, I will talk to you about how to write the sample code of Python to create the artifact of blessing in the year of the Tiger. Many people may not know much about it. In order to make you understand better, the editor has summarized the following content for you. I hope you can get something according to this article.

What is python? Python is a cross-platform, interpretive, compiled, interactive and object-oriented scripting language. Originally designed to write automated scripts, Python is often used to develop independent and large projects as versions are constantly updated and new features are added.

Background story

With the 2022 year of the Tiger approaching, on the occasion of the Spring Festival, communities are scrambling to launch Spring Festival essay solicitation activities. When I was at my wit's end, I was awakened by the small requests of several fans and friends:

Yes, why don't I use Python to draw a tiger and add a few functions to create a blessing artifact for the year of the Tiger! I was inspired in an instant. Without saying much, I looked at the finished product first:

The first is the countdown interface when it was first opened, which is full of mystery:

At the end of the countdown, come to our presentation:

Finally, there are our achievements, always cute little tigers and blessings full of pop-up windows:

Manufacturing process

First, draw the tiger in the Python Turtle module

Here, we use a very interesting library in Python: Turtle, which we often call drawing sea turtles! Students who do not understand can refer to and study this article on their own, and do not explain too much here: sea turtles draw a complete picture-it is worth a look!

1. Definition library and initialization interface def laohu (): import turtle as t # sets the screen size and color t.screensize (50,50, bg='yellow') t.title ("tiger baby") t.shape ("classic") t.pensize (10) t.color ("orange") t.fillcolor ("pink") t.speed (100) t.hideturtle () 2. Draw the left and right ears # t.penup () t.goto (- 105,97) t.setheading (160,160) t.begin_fill () t.pendown () t.circle (- 30,230) t.setheading (180) t.circle (37,90) t.end_fill () # right ear t.penup () t.goto 97) t.setheading (20) t.begin_fill () t.pendown () t.circle (30,230) t.setheading (0) t.circle (- 37,90) t.end_fill () 3. Draw the outline of the tiger's head # t.penup () t.goto (- 67,140) t.setheading (30) t.pendown () t.circle (- 134,60) t.penup () t.goto (- 50,-25) t.setheading (180) t.pendown () t.circle (- 100,30) t.circle (- 30) 90) t.setheading (100,20) t.penup () t.goto (50,25) t.setheading (0) t.pendown () t.circle (100,30) t.circle (30,90) t.setheading (80) t.circle (200,20) 4. Draw the tiger's two eyes # two tiger eyes # left eye t.penup () t.goto (- 90,25) t.setheading (- 45) t.fillcolor ("orange") t.begin_fill () t.pendown () # Ellipse drawing technique a = 0.2for i in range (120): if 0

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