Python深度学习及智能车竞赛实践(一):Python 基础知识体系
Published in:2024-02-28 | category: 智能车
Words: 163 | Reading time: 1min | reading:

求平方

1
2
3
numbers = [1, 2, 3, 4, 5]
squard_numbers = [num**2 for num in numbers]
print(squard_numbers)

绘制同心圆

1
2
3
4
5
6
7
8
9
10
11
12
13
import turtle

turtle.circle(50) #画一个圆
turtle.penup() #画笔悬空
turtle.goto(0, -50) #画笔移动(由于悬空,没有移动痕迹)
turtle.pendown() #画笔放下

turtle.circle(100)
turtle.penup()
turtle.goto(0, -100)
turtle.pendown()

turtle.circle(150)

只画一个圆时,不需要

1
2
3
turtle.penup()
turtle.goto(0, -50)
turtle.pendown()

为了实现同心圆,需要加上。
** 不加后果 **

1
2
3
4
5
6
7
8
9
10
11
12
13
import turtle

turtle.circle(50)
# turtle.penup()
# turtle.goto(0, -50)
# turtle.pendown()

turtle.circle(100)
turtle.penup()
turtle.goto(0, -100)
turtle.pendown()

turtle.circle(150)

输出:

1
2
3
4
5
6
7
8
9
10
11
12
13
import turtle

turtle.circle(50)
# turtle.penup()
# turtle.goto(0, -50)
# turtle.pendown()

turtle.circle(100)
# turtle.penup()
# turtle.goto(0, -100)
# turtle.pendown()

turtle.circle(150)

输出:

Prev:
蓝桥杯stm32学习笔记(四):LCD液晶屏显示
Next:
STM32考核作业