first steps in python

First of all, do we know if we need a kitchen for cooking?

       bingo!

 

So, if we want to use python, do we have to build an environment for python first?

How to build a "kitchen" for python:

1. Install python:

         (1) Double-click to open the file;

         (2) After opening the file, take a photo first (trust me, this photo is critical)

         (3) Click on the red frame;

               

 

         (4) Keep clicking next until finish appears, click to complete the installation;

         (5) Open the photo you just took, and then in the box above, the place where the mouse points is called the path (that is, where your python is installed),

                  Open the python folder with that path, then copy that path, ok, you're half done:

                 

                 

 

                

2. Configure environment variables:

          Configuring environment variables requires doing this:

          (1) Right-click on this computer and click Properties

            

            (2) Click to open "Advanced System Settings" on the left

            

       (3) Click to open "Environment Variables"

           

            (4) Find a "path" thing in the system environment variable, and double-click to open it;

              

             (5) Click New, then in the circle, paste the path you just copied, then click OK, and click OK for each pop-up box;

               

              (6) Test it, search for it in the start menu, enter cmd, and then click the Enter key, and a black box will pop up;

               

              (7) Enter python in the black box, if python will appear below, congratulations, all environments are successfully built (don't close the black box first, there is an easter egg);

               

            (8) Copy the following code, then right-click and paste in the black box:

import turtle

# 设置初始位置
turtle.penup()
turtle.left(90)
turtle.fd(200)
turtle.pendown()
turtle.right(90)

# 花蕊
turtle.fillcolor("red")
turtle.begin_fill()
turtle.circle(10,180)
turtle.circle(25,110)
turtle.left(50)
turtle.circle(60,45)
turtle.circle(20,170)
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)
turtle.fd(20)
turtle.left(155)
turtle.circle(150,80)
turtle.left(50)
turtle.circle(150,90)
turtle.end_fill()
 
# 花瓣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)

# 花瓣2
turtle.left(180)
turtle.circle(90,40)
turtle.circle(-80,98)
turtle.setheading(-83)

# 叶子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)
 
# 叶子2
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,60)

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325112740&siteId=291194637