1 Star 0 Fork 0

mamh-mixed/python-cookbook

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
Calculate resistance.py 435 Bytes
一键复制 编辑 原始数据 按行查看 历史
Ratnesh Kumar 提交于 2024-07-30 00:47 +08:00 . Add exception handling
def res(R1, R2):
sum = R1 + R2
if option =="series":
return sum
elif option =="parallel" :
return (R1 * R2)/sum
return 0
Resistance1 = int(input("Enter R1 : "))
Resistance2 = int(input("Enter R2 : "))
option = input("Enter series or parallel :")
print("\n")
R = res(Resistance1,Resistance2 )
if R==0:
print('Wrong Input!!' )
else:
print("The total resistance is", R)
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/mamh-mixed/python-cookbook.git
git@gitee.com:mamh-mixed/python-cookbook.git
mamh-mixed
python-cookbook
python-cookbook
master

搜索帮助