python 学习 美元人民币转换、变化颜色贪吃蛇、等边三角形绘制、叠加等边三角形、正方形螺旋线 DAY12

1、美元人民币转换

getdatas = input("请输入【¥$】数字:")
if getdatas[0] == '$':
    n = eval(getdatas[1:])
    print("换算是¥{:.2f}".format(n*6))
elif getdatas[0] == '¥':
    m = eval(getdatas[1:])
    print("换算是${:.2f}".format(m/6))
else:

    print("输入有误")

2、变化颜色贪吃蛇

from turtle import *
setup(800,600)
penup()
fd(-300)
pendown()
pensize(25)
speed(10)
color(1,0,0)
fd(40)
seth(-40)
for i in range(4):
    color(0,0,i/4)
    circle(40,80)
    color(i/4,0,0)
    circle(-40,80)
circle(40,40)
color(0,i/4,0)
fd(40)
circle(16,180)

fd(40 * 2/3)

3、等边三角形绘制

from turtle import *
setup(800,600)
pensize(10)
speed(10)
color("blue")
fillcolor("yellow")
begin_fill()
fd(100)
for i in range(1,3):
    
    seth(120*i)
    fd(100)
end_fill()
hideturtle()

done()

4、叠加等边三角形

from turtle import *
setup(800,600)
pensize(2)
speed(10)
color("blue")
fd(200)
for i in range(1,3):    
    seth(120*i)
    fd(200)
penup()
seth(60)   #绝对角度
fd(100)
seth(0)
pendown()
for j in range(1,4):
    fd(100)
    seth(-120*j)
hideturtle()

done()

5、正方形螺旋线

from turtle import *
setup(800,600)
pensize(2)
speed(10)
color("blue")

for i in range(50):    
    seth(90*i)
    fd(5*i)

hideturtle()

done()


  • 4
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值