我想开发一个电子计算器:
将货币转换为单位(KWh)。
它还需要用户输入来确定他/她在家中使用了多少电器元件,以确定每天的平均用电量。
在输入和计算这些数据后,它还将显示他/她可以有多少天,而他/她可以再充电(例如:10美元,他可以有100千瓦时,如果平均每天使用10千瓦时,他/她可以有多少天?[日=100kwh/10kwh=10天]
我已经用两个函数解决了1和2的问题,现在我想用这两个函数的最终值来得到一天。我试着划分这些函数的最后一个。有没有可能把这些函数的值除以?你知道吗
def money_to_unit():
recharge=int(input("Enter yor recharge amount : "))
amount=recharge-(recharge*(5/100)) # after deducting 5% vat
unit=0
if amount<=300: #300 is max value for using 75 Kwh
unit=amount/4 # 4 is the slab rate for 0-75 Kwh
elif amount<=981.25: #981.25 is max value for using 200 Kwh
unit=75+((amount-300)/5.45) #5.45 is the slab rate for 76-200 Kwh
elif amount<=1551.25: #1551.25 is max value for using 300 Kwh
unit=75+125+((amount-681.25)/5.7) #5.7 is the slab rate for 201-300 Kwh
elif amount<=2153.25:
unit=75+125+100+((amount-1551.25)/6.02)
elif amount<=4013.25:
unit=75+125+100+100+((amount-2153.25)/9.30)
else:
unit=75+125+100+100+200+((amount-4013.25)/10.7)
print("Useable amount is :"+ " "+str(round(amount,2))+" "+"Taka")
print("Useable unit is: "+" "+str(round(unit,2))+" "+"Kwh")
money_to_unit()
def comp():
light=int(input("Enter the number of light :"))
watt=int(input("Enter the watt : "))
hour=int(input("Enter the agerage use of light in hour per day : "))
consumption=(light*watt*hour)/1000
print("you total consumption is"+ " " + str(consumption)+ " " + "Kwh per day")
comp()
money_to_unit()
除以comp()
。怎么做?你知道吗(1).500塔卡,可用量475塔卡,可用单位107.11千瓦时
(2).对于每小时20W的5盏灯,每天使用6小时,平均每天使用0.6kWh。你知道吗
(三)。天=107.11 Kwh/0.6 Kwh=178.5天
两个函数都应该返回要用于进一步计算的计算值(而不仅仅是打印)。你知道吗
以及
然后您可以简单地调用如下函数:
最后你可以用x,y,z进行任何额外的计算,比如:
使用
return
。为函数指定要执行的任务,而不仅仅是围绕一些脚本。你知道吗1.第一步定义两个函数:
以及
2.为第二步定义另一个函数:
3.定义最后一个函数:
然后进行计算:
也许:
输出:
相关问题 更多 >
编程相关推荐