Children's programming python-Level 1

Children's programming python

foreword

plan to learn programming

CSP_S Level Exam

CSP-J and CSP-S

The full name of CSP-J is Certified Software Professional Junior, which is the entry level. As the name suggests, it is prepared for beginners who learn programming, and the participants are mostly primary school students and junior high school students.

The full name of CSP-S is Certified Software Professional Senior, that is, the improvement group. It is prepared for the certifiers who already have a certain programming ability foundation. Most of the participants are junior and high school students.

There is only a difference in difficulty between the two, and the organizational form is the same. Both have two rounds of certification, which are equivalent to the preliminary round (first round: CSP-J1/CSP-S1) and the semi-final round (second round: CSP-J2/CSP-S2). The first round examines general and practical computer science knowledge, mainly based on written tests, and some provinces and cities are certified by computer tests. The second round is program design, which must be debugged on a computer. Only those who pass the first round are eligible to enter the second round.

Gold content ranking of children's programming certificate (nationally recognized children's programming certificate)

Which one is more worth taking for the children's programming level test?

Non-Professional Software Competency Certification (CSP-J/S)

Snipaste_2023-05-28_11-24-49

Official website: https://www.noi.cn/

Sponsor: China Computer Federation (CCF)

Exam content: C++, divided into CSP-J and CSP-S with two rounds of certification respectively.

The first stage: basic knowledge, data structure (introduction)

The second stage: algorithm, computer operation (computer, programming)

examination time:

Usually held in October-November

Helpful for further studies:

Senior high school entrance examination, students with special skills in science and technology, extra points for recommended ranking in the school; college entrance examination, self-enrollment quota. Those with excellent results in CSP-J/S certification can participate in NOI provincial selection, and those with excellent results in provincial selection can participate in NOI.

For applicants, CCF's suggestion is: CSP-J/S is open to all interested parties. If your child has excellent strength, high ability, or has a competition plan in the future, you can try to apply for the exam.

Youth Programming Aptitude Test (CPA)

Snipaste_2023-05-28_11-25-55

Sponsor: China Youth Palace Association

Examination Content:

Scratchtu Graphical Programming Level 1-3

Python Programming Level 1-4

C++ language programming level 1-5

examination time:

Usually in April, August, and December each year.

Certificate gold content:

After passing the exam, you will get the official authoritative certificate issued by the China Youth Palace Association for the evaluation of youth programming ability level.

The certificate has high gold content and is a proof of the quality education level ability of children growing up. As an important reference for the quality evaluation report, it has an important impact on enriching children's resumes and improving their competitiveness in the middle and college entrance examinations.

Lanqiao Cup Youth Information Technology Grade Examination

Snipaste_2023-05-28_11-27-50

Sponsor: Blue Bridge Cup Competition Organizing Committee

Official website: https://www.lanqiaoqingshao.cn/home

Examination Content:

Snipaste_2023-05-28_11-43-55

Scratch: 18 levels in total

Pothon: 18 levels in total

C++: 18 levels in total

examination time:

April, May and June 2022

Exam Group:

The Blue Bridge and other exams are grade exams held by the Talent Exchange Center of the Ministry of Industry and Information Technology. One payment can cover three years of grade exams, from level 1 to level 18, and one payment can be taken at will. The test groups of Lanqiao and other exams include three groups, Scratch group, Python group and C++ group.

Gold content:

Since its establishment, because of its authority and professionalism in the computer field, computer majors from more than 1,500 colleges and universities including Peking University and Tsinghua University have participated in the Blue Bridge Cup Competition. The award-winning results of the competition are an important reference in the recruitment of internationally renowned technology companies.

National Youth Software Programming Level Examination

Snipaste_2023-05-28_11-29-01

Sponsor: Chinese Institute of Electronics

Website: https://www.qceit.org.cn/

Exam Group:

Software programming (C language, Python, graphics)

Snipaste_2023-05-28_11-35-10

Examination Content:

1. Programming test: software programming (C language) is composed of programming questions; software programming (Python) and software programming (graphical) are composed of objective questions and programming questions. During the exam, the programming environment embedded in the exam system will be used to realize the programming process and debugging.

2. Practical exams: robotics, 3D creative design, drone technology, and electronic technology are composed of two parts: theoretical synthesis (using online exams) and practical operations (using relevant hardware equipment).

examination time:

Usually in March, June, September and December every year

Gold content:

The officially certified national grade examination comprehensively examines the knowledge reserve and practical ability of young people in software programming, laying the foundation for young people to enter the field of artificial intelligence applications. After the child passes the test, a corresponding level test certificate will be issued to provide proof of software programming ability and level for him to enter a higher school and study abroad.

Download of a sea turtle editor

Website: https://shequ.codemao.cn/Snipaste_2023-05-26_22-20-25

Snipaste_2023-05-26_23-01-35

2 English typing practice website recommendation | Touch typing

1 TypingClub

TypingClub: https://www.typingclub.com/

Among the recommended typing practice websites searched on the site, TypingClub has attracted the author's attention from all the typing practice websites with its simple and beautiful website interface. Many other typing practice website pages seem to have stayed more than ten years ago. The course content on the TypingClub website is interesting and the pages are beautiful.

The Typing Jungle course allows learners to quickly become familiar with standard typing fingerings, and fingering hints can be turned on or off by themselves. The teaching is carried out step by step. As the levels progress, learners gradually learn to input 26 letters of lowercase and uppercase, punctuation marks, numbers, and special symbols.

After clearing all levels with five stars, you can have a speed of at least 75WPM, and if you want to achieve all perfect scores, you can have a speed of at least 150WPM.

TypingClub also supports typing exercises in 16 languages ​​including Chinese Quanpin. I have typed hundreds of Chinese courses and think it has two shortcomings: 1. Some Chinese pinyin is wrong 2. Most of the levels can only use Hit \, hit / to calculate wrongly.

Although TypingClub is good, but the domestic access speed is slow, so many people cannot open the website for a long time.

Snipaste_2023-05-27_10-28-45

2 Typing

Typing: https://www.typing.com/ can only be accessed by foreigners who have obtained magic

Typing is similar to TypingClub. If you really can’t use TypingClub, you can try to use Typing to learn typing fingering. There are also fingering tips. The video loading on the website is a bit slow, so you can skip it and learn fingering directly. The course setting has more teaching of small keyboards than TypingClub, and the total number of courses is less.

Typing also provides typing exercises in three programming languages: HTML, CSS, and JavaScript.

Qwerty Learner

Qwerty Learner: https://qwerty.kaiyi.cool/

This website does not have fingering teaching, so it is suitable for people who can touch type. The website itself is designed for keyboard workers to memorize words and exercise English muscle memory.

The site contains lexicons such as CET-4 and CET-6, PubMed, Specialized Four, Specialized Eight, GMAT, GRE, IELTS, SAT, TOEFL, etc. It also includes words from the third grade to high school in the People's Education Edition, new concept English, and common English words for programmers library etc.

Snipaste_2023-05-28_00-43-01

Snipaste_2023-05-28_00-50-06

3 TypeLit

TypeLit:https://www.typelit.io/

Typelit is suitable for people who can touch type. First, choose a classic novel and type while reading the novel. Currently, the website supports novels in English and several other minor languages, and English has the largest collection.

Snipaste_2023-05-27_10-54-27

4 Typing sound effects

Tickeys to find the feeling of typing

Tickeys: https://www.yingdev.com/projects/tickeys

5 VisuAlgo (data structure and algorithm visualization learning website)

Official website: https://visualgo.net/zh/

Three python language interface introduction

1 What is python

Python is a computer programming language. You may have heard of many popular programming languages, such as the very difficult C language, the very popular Java language, JavaScript suitable for web programming, etc. Python is one of them compared to
other As a programming language, Python has its own unique advantages, and it can complete tasks with very little code. For example, to complete the same task, C language needs to write 1000 lines of code, Java needs 100 lines, and Python may only need 20 lines, so Python is a very advanced programming language

2 What can python do

1. Web development : server-side programming, with rich web development frameworks, such as Django and TurboGears, to quickly complete the development of a website and web services.

2. Crawlers, data analysis, data mining, machine learning.

3. Scientific computing : Python is widely used in scientific and digital computing, such as bioinformatics, physics, architecture, geographic information systems, image visualization analysis, life sciences, etc., commonly used numpy, SciPy, Biopython, SunPy, etc.

4. Operation and maintenance automation : Automate the processing of a large number of operation and maintenance tasks

5. Test automation : It is written as a simple implementation script and used in Selenium/lr to realize automation.

6. Graphical interface development : Python can write desktop graphical user interfaces, and can also extend Microsoft Windows, commonly used Tk, GTK+, PyQt, win32, etc.

7. Game development : Python has a good 3D rendering library and game development framework, and there are many games developed using Python, such as Disney Toontown and Blade of Darkness. Commonly used PyGame, Pykyra, etc. and a PyWeek game.

Of course, we can also play with WeChat emoticons

import turtle  # 导入库
turtle.TurtleScreen._RUNNING = True  # 用来避免xx问题,具体什么问题我忘记了
pen = turtle.Pen()
pen.speed(10)  # 设置笔速度
#画外圆
pen.pencolor()  # 设置笔颜色
pen.penup()  # 提笔
pen.goto(0, -100)  # 移动位置
pen.pendown()  # 放笔
pen.begin_fill()  # 开始填充
pen.circle(100)  # 画半径为100的圆
pen.fillcolor("#FFFF00")  # 填充颜色
pen.end_fill()  # 结束填充
#画眼睛


def draweye(x):  # 画眼函数
    pen.pencolor()
    pen.penup()
    pen.goto(x, 0)
    pen.pendown()
    pen.begin_fill()
    pen.circle(25)
    pen.fillcolor("#F8F8FF")
    pen.end_fill()
    pen.begin_fill()
    pen.circle(15)
    pen.fillcolor("#000000")
    pen.end_fill()


draweye(-40)  # 画左眼
draweye(40)  # 画右眼

#画嘴巴
pen.right(60)
pen.penup()
pen.goto(-65, -30)
pen.pendown()
pen.circle(75, 120)  # 勾股定理求出75
#将画笔移动中间
pen.penup()
pen.setheading(-90)
pen.goto(0, -20)
#结束画图
turtle.done()

Snipaste_2023-05-31_01-07-38

import turtle
turtle.setup(800, 800)
turtle.speed(10)

turtle.color("yellow")  # 画脸
turtle.begin_fill()
turtle.circle(200)
turtle.end_fill()

turtle.left(90)  # 画嘴
turtle.fd(15)
turtle.right(90)
turtle.color("yellow")
turtle.circle(175, 270)
turtle.color("black")
turtle.circle(175, 180)
turtle.color("yellow")
turtle.penup()
turtle.circle(175, 270)
turtle.pendown()

turtle.color("yellow")
turtle.goto(-179, 258)  # 左白眼
turtle.color("black")
turtle.fillcolor("white")
turtle.begin_fill()
turtle.circle(20, 25)
turtle.circle(-170, 50)
turtle.circle(13, 175)
turtle.circle(150, 38)
turtle.circle(280, 13)
turtle.end_fill()
turtle.goto(-179, 258)
turtle.seth(0)
turtle.color("black")
turtle.begin_fill()
turtle.circle(16)
turtle.end_fill()

turtle.color("yellow")
turtle.goto(26, 258)
turtle.color("black")
turtle.fillcolor("white")  # 右白眼
turtle.begin_fill()
turtle.circle(20, 25)
turtle.circle(-170, 50)
turtle.circle(13, 175)
turtle.circle(150, 38)
turtle.circle(280, 13)
turtle.end_fill()
turtle.goto(26, 258)  # 右黑眼坐标
turtle.seth(0)
turtle.fillcolor("black")
turtle.begin_fill()
turtle.circle(16)
turtle.end_fill()

turtle.pencolor("black")  # 右眉毛
turtle.penup()
turtle.goto(60, 338)  # 右眉毛尖坐标
turtle.pendown()
turtle.fillcolor("black")
turtle.begin_fill()
turtle.seth(25)
turtle.circle(-90, 34)
turtle.seth(-25)
turtle.circle(-150, 30)
turtle.left(155)
turtle.circle(80, 55)
turtle.circle(60, 80)
turtle.end_fill()

turtle.pencolor("black")  # 左眉毛
turtle.penup()
turtle.goto(-53, 338)
turtle.pendown()
turtle.fillcolor("black")
turtle.begin_fill()
turtle.seth(155)
turtle.circle(90, 34)
turtle.seth(205)
turtle.circle(150, 30)
turtle.left(-155)
turtle.circle(-80, 55)
turtle.circle(-60, 80)
turtle.end_fill()
turtle.penup()
turtle.color("yellow")
turtle.fd(10)
turtle.done()

ircle(-60, 80)
turtle.end_fill()
turtle.penup()
turtle.color("yellow")
turtle.fd(10)
turtle.done()

Snipaste_2023-05-31_01-09-32

3 python development tools

Snipaste_2023-05-31_00-15-00

Snipaste_2023-05-31_00-17-03

4 python tool installation

See python learning on desktop

Snipaste_2023-05-31_00-19-34

Snipaste_2023-05-31_00-20-07

5 run python

The first

Open

Snipaste_2023-05-27_11-43-45

image-20230602164731829

Snipaste_2023-05-27_11-48-09

It can only be created line by line and there is no way to write too many lines, so we have to use

Snipaste_2023-05-27_11-49-49

Snipaste_2023-05-27_11-55-31

Save crrl+S

Snipaste_2023-05-27_11-57-07

Snipaste_2023-05-27_12-00-32

run

Snipaste_2023-05-27_12-02-18

Snipaste_2023-05-27_12-03-23

set font size

Snipaste_2023-05-27_12-05-48

Snipaste_2023-05-27_12-06-28

the second

win+r

Snipaste_2023-05-27_12-09-06

Snipaste_2023-05-27_12-09-47

Snipaste_2023-05-27_12-10-19

Copy the path we saved

Snipaste_2023-05-27_12-13-15

Snipaste_2023-05-27_12-13-47

Four print () function

The print() function and comments of the built-in function

Snipaste_2023-05-27_12-17-38

Five python variables

Variable role: used to temporarily store data

Grammar format (emphasis): variable name = variable value

The variable name is equivalent to a box. The variable value is equivalent to a basketball. You can put a basketball or a paper towel in a basketball. Putting a basketball or a paper towel in a box is called assignment.

Variable definition: Assume a = 0, a is the variable name, 0 is the value of the variable, and the = sign means storing 0 in the variable a, also called assignment, assigning a value 0

number = 100
age =12
print(number) print variable number print variable ageprint(age)

Snipaste_2023-05-28_10-38-12

# print[输出函数]
# 语法格式:print(可以放内容)

print(100)
print(99.5)

# 99.5和100放在同一行
print(100,end=" ")
print(99.5)

#写代码在同一行
print(100);print(99.5)

#字符:A,B,C,D,。 [
#字符串:ABCD 小白老师

print("小白老师") #一定是英文的双引号或是单引号
print("小白老师")

# print("小白老师")   #这是错误写法
#复制+粘贴 Ctrl +C  Ctrl+V

Snipaste_2023-05-28_10-42-13

Variables in Python can only contain letters, numbers and underscores, cannot start with a number, and cannot use Python keywords as variable names

Snipaste_2023-05-28_10-52-54

a = 0
A =40
b = 20
ab = 30
小白老师  = 100

print("小白老师")
print(小白老师)
print()
print(A)
print(ab)



#123_abc = 100 #不可以
a123 = 100
#/abc = 200
# 特殊符号不行: / 。 , 、 [] - = + #  % $ & *
abc =200 

# if is for 关键字
a = 200
b = 300
print(a)
print(b)

Snipaste_2023-05-28_10-53-55

Snipaste_2023-05-28_10-54-49

multiple variable assignment

for example

Snipaste_2023-05-28_10-59-38

Six python data types

int of integer type

Integer type related: such as 1 to 100000, -1 to -10000... represented by int

Define an integer type variable

a=100
b=1000
c=-100
d=-2335

float of floating point type

Floating-point number type: related to the decimal point, such as 1.5, 0.5, 10.8... represented by float

bool of Boolean type

Represented by bool, there are only two values ​​of True and False. True is represented by 1, and False is represented by 0.

str of string type

Snipaste_2023-05-28_20-42-10

Snipaste_2023-05-28_20-43-15

Snipaste_2023-05-28_20-44-04

# 数据类型:整数类型、浮点数类型、布尔类型、字符串类型
a = 1000   # 整数类型的变量
b = 3.14    # 浮点数类型的变量
c = True  
d="小白老师"    # 字符串类型的变量,双引号
e='小白'         # 字符串类型的变量,单引号
# 字符串类型的变量,三引号
g ='''

数据类型:布尔类型数据类型:整数类型、布尔类型、字符串类型 浮点数类型
数据类型:布尔类型数据类型:整数类型、布尔类型、字符串类型 浮点数类型
'''
print(a)
print(b)
print(c)
print(d)
print(e)
print(g)

Snipaste_2023-05-28_20-55-36

The type() function of the built-in function

Snipaste_2023-05-28_21-11-08

Snipaste_2023-05-28_21-11-35

# 数据类型:整数类型(int)、浮点数类型(float)、布尔类型(bool)、字符串类型(string)
a = 1000   # 整数类型的变量
a123 = "1000"
b = 3.14    # 浮点数类型的变量
c = True  
d="小白老师"    # 字符串类型的变量,双引号
e='小白'         # 字符串类型的变量,单引号
# 字符串类型的变量,三引号
g ='''
数据类型:布尔类型数据类型:整数类型、布尔类型、字符串类型 浮点数类型
数据类型:布尔类型数据类型:整数类型、布尔类型、字符串类型 浮点数类型
'''
# type() 函数是用于查看数据类型的
a_1 = type(a)
print(a,a_1)
# 也可以这样写
print(a123, type(a123))
print(b,type(b))
print(c,type(c))
print(d,type(d))
print(e,type(e))
print(g,type(g))

============================================ RESTART: D:/少儿python作品/自带IDE写的/lesson_4.py ===========================================
1000 <class 'int'>
1000 <class 'str'>
3.14 <class 'float'>
True <class 'bool'>
小白老师 <class 'str'>
小白 <class 'str'>

数据类型:布尔类型数据类型:整数类型、布尔类型、字符串类型 浮点数类型
数据类型:布尔类型数据类型:整数类型、布尔类型、字符串类型 浮点数类型

type() function function: used to check what type the content is Grammar format (emphasis): type (content), such as type('100')

Seven pythony calculation operators

Snipaste_2023-05-28_21-20-16

Conversion between eight data types

Int() built-in function of integer type

Snipaste_2023-05-28_21-23-29

float() function

Snipaste_2023-05-28_21-30-55

str() function

str()函数作用:用于将其他数据类型转换成字符串类型,能转换所有基本数据类型语法格式 (重点):str(数据类型) 如str(11),str(11.11)
# int 把整型转换成字符串并打印转换后的类型
print(str(11), type(str(11)))
# float 把浮点型转换成字符串并打印转换后的类型
print(str(11.11), type(str(11.11)))
# bool 把布尔型转换成字符串并打印转换后的类型
print(str(True), type(str(True)))

bool() function

bool()函数作用:用来将字符串类型、浮点数类型、布尔类型的数据转成布尔类型
语法格式 (重点): int(其他数据类型)、如int(12.99)
#将字符串类型转成布尔类型
print(bool("199"))
#将浮点数类型转成布尔类型
print(bool(12))
#将布尔类型转成布尔类型
print(bool(True))
#有字符数据都会返回True
print(bool("0"))
#除了0返回False,其他数都返回True
print(bool(0))
#返回True
print(bool(-1))

string interception

The grammatical format of string interception is as follows: variable [head subscript: tail subscript: step size] **

Snipaste_2023-05-28_21-50-58

count() function

count() function function: used to count the number of times a certain character appears in a string Syntax format (emphasis): string.count(character), such as character variable.count(character)

举例:
a="abcabcabbcabcdabcd"
print(a.count("a")) #count()函数,用于计算某个字符出现多少次

Nine relational operators

Snipaste_2023-05-28_21-58-41

ten logical operators

Snipaste_2023-05-28_22-29-15

Snipaste_2023-05-28_22-31-07

[External link picture transfer failed, the source site may have an anti-theft link mechanism, it is recommended to save the picture and upload it directly (img-gI6yv5lP-1685696211547) (E:\Children's python\img\Snipaste_2023-05-28_22-32-44.png )]

Eleven input functions

The input0 function of the built-in function

Snipaste_2023-05-28_22-38-58

Snipaste_2023-05-28_22-43-29

Twelve Turtle Libraries

turtle library

Cartesian coordinates

Cartesian coordinate system

Snipaste_2023-05-28_22-47-28

Snipaste_2023-05-28_22-48-11

Import the turtle library

Example 1: (create a pen)
import turtle
pen=turtle.Turtle 0
pen.pensize 20)
#Set the width of the
pen pen.penco lor(“red”)#Set the color of the pen

Example 2: (No need to create a pen)
import turtle as t
t.speed(10) #Set the moving speed of the brush, 0-10, the maximum is 10, the larger the number, the slower the speed

t.pensize(20) #Set the width of the brush

t.pencolor("red") #Set the color of the brush

t.fillcolor("blue")#Draw the fill color of the graph
t.begin_fill() #Start filling the color
t.circle(50,steps=3) #Draw a triangle, steps=3 is the triangle
t.end_fill() #End filling Color
t.done() #Represents the painting is finished

#导入海龟库,建立别名叫t
import turtle  as t

# pen = turtle.Turtle()  # 建立一支笔


# 行走相关
# t.forward(100) # 往前走100像素
t.fd(100)   #与上面代码一样 这是简写函数
# t.backward(200)  #往后走100像素
t.bk(200)         #与上面代码一样 这是简写函数

# 方向相关:两种方式
# 第一种方式
# t.left(90)   #左转
t.lt(90)
t.fd(100)

# t.right(90)  #右转
t.rt(90)
t.fd(200)

# 第二种方式:角度方向
t.setheading(90)    #面向90度方向
t.bk(100)

t.setheading(180)
t.fd(100)

# t.setheading(270)与t.setheading(-90)方向一样
# t.setheading(90)与t.setheading(-270)方向一样
# t.setheading(180)与t.setheading(-180)方向一样
# t.setheading(-90)   #缩写
t.seth(-90)
t.fd(400)

Snipaste_2023-05-29_00-29-33

import turtle as t
# 设置画布
t.setup(800,400,0,0)
t.screensize(500,500,"yellow")


t.speed(0) #画笔的速度,范围0-10,越小的值速度越快
t.pensize(10) # 画笔大小
t.color("red") # 画笔的颜色
t.pencolor("blue") # 画笔的颜色
t.fd(100) 

Snipaste_2023-05-29_00-46-45

Canvas initialization

Snipaste_2023-05-29_00-23-10

Snipaste_2023-05-29_09-35-56

Snipaste_2023-05-29_10-02-12

setheading(angle)  设置当前朝向为angle角度
home() 设置当前画笔位置为原点 
dot(r) 绘制一个指定直径和颜色的点

Snipaste_2023-05-29_10-07-02

turtle.hideturtle()      # 隐藏箭头   隐藏画笔的turtle形状
turtle.showturtle()      # 显示箭头   显示画笔的turtle形状

Snipaste_2023-05-29_11-22-28

import turtle as t

t.speed(0) # 加速

t.fillcolor("red")
t.begin_fill()   # 开始
t.fd(100)  # 往前走100像素
t.lt(90)   # 左转90度(逆时针) 箭头朝上
t.fd(100)  # 往前走100像素
t.lt(90)   # 左转90度(逆时针) 箭头朝左
t.fd(100)  # 往前走100像素
t.lt(90)   # 左转90度(逆时针) 箭头朝下
t.fd(100)  # 往前走100像素
t.lt(90)   # 左转90度(逆时针) 箭头朝右
t.end_fill()   # 结束

# t.hideturtle()      # 隐藏箭头   隐藏画笔的turtle形状

#上面的步骤就可以画出一个正方形

# 如果是长方形
# t.fd(150)  # 往前走100像素
# t.lt(90)   # 左转90度(逆时针) 箭头朝上
# t.fd(80)  # 往前走100像素
# t.lt(90)   # 左转90度(逆时针) 箭头朝左
# t.fd(150)  # 往前走100像素
# t.lt(90)   # 左转90度(逆时针) 箭头朝下
# t.fd(80)  # 往前走100像素
# t.lt(90)   # 左转90度(逆时针) 箭头朝右
# t.hideturtle()      # 隐藏箭头   隐藏画笔的turtle形状

t.up()            # 抬笔、t.pcnup() t.pu()
t.goto(-300,300)     # 移到(x,y)指定的坐标位置
t.down()    # 落笔、t.pendown()
t.fd(100)     # 往前走100像素
t.seth(270)    # 往下的方向270 、-90
t.fd(100)      # 往前走100像素
t.seth(-180)    #往左的方向180 、-180
t.fd(100)
t.seth(90)    # 往上的方向90 、-270
t.fd(100)      # 往前走100像素
t.rt(90)       # 右转90度(顺时针)


t.fillcolor("yellow")
t.begin_fill()

t.fd(50)    # 往前走50像素
t.rt(45)    # 右转45度(顺时针)
t.fd(70)    # 往前走70像素
t.rt(90)    # 右转90度(顺时针)
t.fd(70)    # 往前走70像素


t.rt(90)    # 右转90度(顺时针)
t.fd(70)    # 往前走70像素
t.rt(90)    # 右转90度(顺时针)
t.fd(70)    # 往前走70像素
# t.hideturtle()      # 隐藏箭头   隐藏画笔的turtle形状

t.end_fill()

t.ht()   # 隐藏箭头   隐藏画笔的turtle形状

t.st()   # 显示箭头   显示画笔的turtle形状

#清空两种方式: clear()函数reset门)函数
# t.clear()    # 清空窗口内容但是不清除状态
t.reset()     # 清空窗口内容清除状态、回到原始样子

t.shape("turtle") # turtle的形状、circle 圆  
t.fd(70)    # 往前走70像素
t.stamp()   # 印章
t.rt(90)    # 右转90度(顺时针)
t.fd(70)    # 往前走70像素
t.undo()    # 撤销上一个动作

t.done() # 结束画画

Snipaste_2023-05-29_11-35-37

Thirteen Python assignment operators

Snipaste_2023-05-29_11-38-23

Snipaste_2023-05-29_11-39-14

Snipaste_2023-05-29_11-41-16

Python3.8 or above can be used

Snipaste_2023-05-29_11-42-18

Import "Turtle Editor" for drawing

Draw a rectangle with a length of 150 and a width of 80

Snipaste_2023-05-31_00-41-24

Snipaste_2023-05-31_00-42-12

Snipaste_2023-05-31_00-43-24

Snipaste_2023-05-31_00-44-18

Snipaste_2023-05-31_00-45-28

Snipaste_2023-05-31_00-47-11

Snipaste_2023-05-31_00-48-21

Snipaste_2023-05-31_00-49-05

Snipaste_2023-05-31_00-50-23

import turtle as t
# 第一种办法
# t.speed(0) # 加速  1 最慢  0最快
# t.forward(150)  # 往前走150像素
# t.left(90)  # 左转90度(逆时针) 箭头朝上
# t.forward(80)  # 往前走80像素
# t.left(90)  # 左转90度(逆时针) 箭头朝上
# t.forward(150)  # 往前走150像素
# t.left(90)  # 左转90度(逆时针) 箭头朝上
# t.forward(80)  # 往前走80像素
# t.left(90)  # 左转90度(逆时针) 箭头朝上
# t.hideturtle() # 隐藏箭头   隐藏画笔的turtle形状
# t.done()
# 第二种办法(缩写)
# 画一个是长方形
# t.fd(150)  # 往前走150像素
# t.lt(90)   # 左转90度(逆时针) 箭头朝上
# t.fd(80)  # 往前走80像素
# t.lt(90)   # 左转90度(逆时针) 箭头朝左
# t.fd(150)  # 往前走150像素
# t.lt(90)   # 左转90度(逆时针) 箭头朝下
# t.fd(80)  # 往前走100像素
# t.lt(90)   # 左转90度(逆时针) 箭头朝右
# t.hideturtle()      # 隐藏箭头   隐藏画笔的turtle形状
# t.done()
# 第三种办法  for
t.speed(1)     # 加速  1 最慢  0最快
for i in range(2):
    t.forward(150)
    t.left(90)
    t.forward(80)
    t.left(90)
t.hideturtle()      # 隐藏箭头   隐藏画笔的turtle形状
t.done()

External link image transfer...(img-c2D4tPHn-1685696211562)]

[External link image transfer...(img-KRCRJFBU-1685696211563)]

[External link image transfer...(img-AtWJdQml-1685696211563)]

[External link image transfer...(img-x4Ao2fcY-1685696211564)]

[External link image transfer...(img-Zq8o5r1S-1685696211564)]

[External link image transfer...(img-m69hOl5i-1685696211565)]

[External link image transfer...(img-R0MlRVs5-1685696211565)]

[External link image transfer...(img-G7Yqr0Le-1685696211565)]

import turtle as t
# 第一种办法
# t.speed(0) # 加速  1 最慢  0最快
# t.forward(150)  # 往前走150像素
# t.left(90)  # 左转90度(逆时针) 箭头朝上
# t.forward(80)  # 往前走80像素
# t.left(90)  # 左转90度(逆时针) 箭头朝上
# t.forward(150)  # 往前走150像素
# t.left(90)  # 左转90度(逆时针) 箭头朝上
# t.forward(80)  # 往前走80像素
# t.left(90)  # 左转90度(逆时针) 箭头朝上
# t.hideturtle() # 隐藏箭头   隐藏画笔的turtle形状
# t.done()
# 第二种办法(缩写)
# 画一个是长方形
# t.fd(150)  # 往前走150像素
# t.lt(90)   # 左转90度(逆时针) 箭头朝上
# t.fd(80)  # 往前走80像素
# t.lt(90)   # 左转90度(逆时针) 箭头朝左
# t.fd(150)  # 往前走150像素
# t.lt(90)   # 左转90度(逆时针) 箭头朝下
# t.fd(80)  # 往前走100像素
# t.lt(90)   # 左转90度(逆时针) 箭头朝右
# t.hideturtle()      # 隐藏箭头   隐藏画笔的turtle形状
# t.done()
# 第三种办法  for
t.speed(1)     # 加速  1 最慢  0最快
for i in range(2):
    t.forward(150)
    t.left(90)
    t.forward(80)
    t.left(90)
t.hideturtle()      # 隐藏箭头   隐藏画笔的turtle形状
t.done()

Guess you like

Origin blog.csdn.net/m0_59281987/article/details/131010575