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)

第一部分 初识python语言 -2

相关文章:

  • 2021-07-13
  • 2021-08-20
  • 2022-01-22
  • 2021-07-01
  • 2021-11-01
  • 2021-04-22
  • 2022-01-15
  • 2021-12-05
猜你喜欢
  • 2021-04-13
  • 2021-08-17
  • 2021-11-11
  • 2021-12-27
  • 2021-07-07
  • 2022-12-23
相关资源
相似解决方案