014 Python基本图形绘制小结
2020-12-13 06:09
标签:port rtl style form 浮点 -o toc one 注释 目录 014 Python基本图形绘制小结 标签:port rtl style form 浮点 -o toc one 注释 原文地址:https://www.cnblogs.com/nickchen121/p/11167698.html
一、Python基本语法元素
1.1 温度转换
# TempConvert.py
TempStr = input("请输入带有符号的温度值: ")
if TempStr[-1] in ['F', 'f']:
C = (eval(TempStr[0:-1]) - 32) / 1.8
print("转换后的温度是{:.2f}C".format(C))
elif TempStr[-1] in ['C', 'c']:
F = 1.8 * eval(TempStr[0:-1]) + 32
print("转换后的温度是{:.2f}F".format(F))
else:
print("输入格式错误")
二、Python基本图形绘制
2.1 Python蟒蛇绘制
import turtle
turtle.setup(650, 350, 200, 200)
turtle.penup()
turtle.fd(-250)
turtle.pendown()
turtle.pensize(25)
turtle.pencolor("purple")
turtle.seth(-40)
for i in range(4):
turtle.circle(40, 80)
turtle.circle(-40, 80)
turtle.circle(40, 80 / 2)
turtle.fd(40)
turtle.circle(16, 180)
turtle.fd(40 * 2 / 3)
turtle.done()