[Python] python简单的函数定义和使用范例 →→→→→进入此内容的聊天室

来自 , 2021-05-01, 写在 Python, 查看 130 次.
URL http://www.code666.cn/view/80a9efd3
  1. def convertTemp(temp, scale):
  2.    if scale == "c":
  3.       return (temp - 32.0) * (5.0/9.0)
  4.    elif scale == "f":
  5.       return temp * 9.0/5.0 + 32
  6.  
  7. temp = int(input("Enter a temperature: "))
  8. scale = input("Enter the scale to convert to: ")
  9. converted = convertTemp(temp, scale)
  10. print("The converted temp is: " + str(converted))
  11. #//python/7396

回复 "python简单的函数定义和使用范例"

这儿你可以回复上面这条便签

captcha