python模块每日作业
1.建立python开发环境并完成第一个程序
-
进入python官网:https://www.python.org.
-
选择操作系统对应的版本,进行下载
-
安装过程中注意勾选“Install for all user”和“Add Add Python to environment variable”两个选项
-
打开IDLE,点击左上角File–>New File,新建一个py文件,在文件内编辑代码
-
在文件内输入print(“hello, python!”),并保存,点击Run–>Run Module运行。
2.绘制奥运五环
代码如下
###########画五环##################
import turtle as t
t.width(10)
t.color("blue")
t.circle(50)
t.penup()
t.forward(120)
t.pendown()
t.color("black")
t.circle(50)
t.penup()
t.forward(120)
t.pendown()
t.color("red")
t.circle(50)
t.penup()
t.goto(60,-50)
t.pendown()
t.color("yellow")
t.circle(50)
t.penup()
t.forward(120)
t.pendown()
t.color("green")
t.circle(50)
3.输出四个矩阵
代码如下
import turtle as t
t.forward(50)
t.left(90)
t.forward(50)
t.left(90)
t.forward(50)
t.left(90)
t.forward(50)
t.left(90)
t.penup()
t.goto(60,0)
t.pendown()
t.forward(50)
t.left(90)
t.forward(50)
t.left(90)
t.forward(50)
t.left(90)
t.forward(50)
t.left(90)
t.penup()
t.goto(0,-60)
t.pendown()
t.forward(50)
t.left(90)
t.forward(50)
t.left(90)
t.forward(50)
t.left(90)
t.forward(50)
t.left(90)
t.penup()
t.goto(60,-60)
t.pendown()
t.forward(50)
t.left(90)
t.forward(50)
t.left(90)
t.forward(50)
t.left(90)
t.forward(50)