首页 > 编程语言 >6.python-练习定义函数

6.python-练习定义函数

时间:2022-12-08 19:14:32浏览次数:41  
标签:return 定义 weight get python 练习 content input def

def print_content(content):
    print(content)

def get_sentence_constituent(sentence,constituent):
    return input("请输入%s的%s:" % (sentence,constituent))
    
def get_commodity_price():
    return float(input("请输入商品单价:"))
    
def get_commodity_quantity():
    return float(input("请输入购买数量:"))

def get_payment_amount():
    return float(input("请输入支付金额:"))

def get_number_people(content):
    return int(input("请输入%s:" % content))

def calculate_cure_ratio(conform,cure):
    return cure / conform * 100

def get_weight(content):
    return int(input("请输入%s:" % content))
    
def calculate_weight(weight):
    jin = weight // 16
    liang = weight % 16
    return jin,liang

 

标签:return,定义,weight,get,python,练习,content,input,def
From: https://www.cnblogs.com/xmgcool/p/16967016.html

相关文章

  • python5
    一、使用字符串拼接输出一个关于程序员的笑话programmer_1='程序员甲:搞IT太辛苦了,我想换行……怎么办?'programmer_2='程序员乙:敲一下回车键'print(programmer_1+programme......
  • Python判断一个变量值是否为数字数值类型
    fromnumbersimportNumberisinstance(x,Number)下面是源代码中关于Number的描述classNumber(metaclass=ABCMeta):"""Allnumbersinheritfromthisclass.......
  • Mybatis自定义拦截器实现自动记录操作人信息
    1.前言Mybatis有四大核心对象,分别是Executor,StatementHandler,ParamterHandler,ResultSetHandler。在很多时候,对表中的数据都需要记录插入时间,修改时间,插入人和修改人,若每......
  • python基础之条件判断语句(笔记)
    #条件判断语句(if语句)#语法:if条件表达式: #     代码块#执行的流程:if语句在执行时,会先对条件表达式进行求值判断,# 如果为True,则执行if后的语句# ......
  • python123_第七周练习_程序设计题
    羽毛球计分规则:1.21分制,3局2胜为佳2.每球得分制3.每回合中,取胜的一方加1分4.当双方均为20分时,领先对方2分的一方赢得该局比赛5.当双方均为29分时,先取得30......
  • 用python计算圆周率PI
    描述用python计算圆周率PI要求能算到小数点后面越多越好(5分)‪‬‪‬‪‬‪‬‪‬‮‬‪‬‫‬‪‬‪‬‪‬‪‬‪‬‮‬‪‬‫‬‪‬‪‬‪‬‪‬‪‬‮‬‪‬‭‬‪‬‪......
  • Python7段数码管绘制
    #七段数码管绘制importturtleastimporttimeasTdefdrawGap():#绘制数码管的间隔t.penup()t.fd(5)defdrawLine(draw):#绘制单段数码管,draw为True时,则实......
  • 高中计算能力提升专项练习
    一、计算下列各式的值:(1)\((-0.6)-\left(-3\frac{1}{4}\right)-\left(+7\frac{2}{5}\right)+2\frac{3}{4}-2\)(2)\(3-\left[(-1)^3-1\right]-|(-2)\div6|\)3(3)......
  • Python 7段数码管绘制
    #七段数码管绘制importturtleastimporttimeasTdefdrawGap():#绘制数码管的间隔t.penup()t.fd(5)defdrawLine(draw):#绘制单段数码管,draw为True时,则实......
  • 第八章练习题
    黑盒测试什么叫等价类划分法?它的意义和步骤等价类划分法是将程序的输入域划分为若干个部分,然后从每个部分选区少数代表数据当作测试用例。意义:完备性,无冗余性。步骤:1......