import turtle as t
import random # 产生随机数
t.color("yellow", "yellow")
t.shape("turtle")
t.width(2)
t.speed(0)
a = 100
b = 144
# bgm
t.bgcolor("black")
for ii in range(100):
t.up()
x = random.randint(-350, 350)
y = random.randint(-200, 200)
t.goto(x,y) # x y
t.down()
t.begin_fill()
for i in range(5):
t.fd(a)
t.rt(b)
t.end_fill()
t.done()
·
命名方法
# import turtle
# import turtle as t # 重命名
# from turtle import left, right, color, done # 从turtle工具包导入left和done的方法
# from turtle import * # 从turtle工具包导入所有方法
#
# # forward ---> fd left ---> lt right --> rt
# color('blue')
# fd(100)
# left(123)
# done()
import random
a = random.randint(1,100) # 产生随机整数
b = random.random() # 产生0-1随机小数
print(a)
print(b)
print(a+b)