目录
Talk is cheap,Show me the code
— Linus Torvalds
温度转换
#e1.1 TempConvert.py
def tempConvert(ValueStr):
if ValueStr[-1] in ['F','f']:
C=(eval(ValueStr[0:-1])-32)/1.8
print("The result temperature is {:.2f}C".format(C))
elif ValueStr[-1] in ['C','c']:
F = (eval(ValueStr[0:-1])*1.8)+32
print("The result temperature is {:.2f}F".format(F))
else:
print("Input format error!")
TempStr = input("请输入带有符号的温度值:")
tempConvert(TempStr)
请输入带有符号的温度值:>? 82F
The result temperature is 27.78C
请输入带有符号的温度值:>? -30C
The result temperature is -22.00F
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)