大家好!今天给你们带来了简单python计算器库,库名jisuanqi可以用来批量完成基础计算。
安装:
pip install jisuanqi
实例:
from jisuanqi import*
result1=jia(4561,456456,463,-5967)
result2=jian(44,4564,555)
result3=cheng(454,3352,3)
result4=chu(99,7676,87)
result5=cifang(2,14)
result6=zuidazhi(2,56578,888)
result7=zuixiaozhi(5672,5678,888)
result8=pingjunzhi(5567,5657,2610)
print("加:",result1)
print("减:",result2)
print("乘:",result3)
print("除:",result4)
print("次方:",result5)
print("最大值:",result6)
print("最小值:",result7)
print("平均值:",result8)
输出:
加:455513
减:-5075
乘:4565424
除:0.00014824531454960379
次方:16384
最大值:56578
最小值:888
平均值:13834
源码:
defjia(*numbers):
return sum(numbers)
defjian(*numbers):
return numbers[0] - sum(numbers[1:])
defcheng(*numbers):
product = 1
for num in numbers:
product *= num
return product
defchu(*numbers):
result = numbers[0]
for num in numbers[1:]:
result /= num
return result
defcifang(base,exponent):
result = base ** exponent
return result
defzuidazhi(*numbers):
return max(numbers)
defzuixiaozhi(*numbers):
return min(numbers)
defpingjunzhi(*numbers):
return sum(numbers)