概述
本文实例讲述了python简单的函数定义和用法。分享给大家供大家参考。具体分析如下:
这里定义了一个温度转换的函数及其用法。
def convertTemp(temp, scale): if scale == "c": return (temp - 32.0) * (5.0/9.0) elif scale == "f": return temp * 9.0/5.0 + 32 temp = int(input("Enter a temperature: ")) scale = input("Enter the scale to convert to: ") converted = convertTemp(temp, scale) print("The converted temp is: " + str(converted))
希望本文所述对大家的Python程序设计有所帮助。
最后
以上就是成就百褶裙为你收集整理的python简单的函数定义和用法实例的全部内容,希望文章能够帮你解决python简单的函数定义和用法实例所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复