与此代码相关的语法错误。曾尝试查找但没有帮助
syntax error related to this code. Have tried looking it up but not helping
我正在尝试创建电阻计算器程序,但出现语法错误。
print("Welcome to resistance calculator!!!")
import time
import math
time.sleep(2)
powersource=int(input("How many volts is your battery?"))
time.sleep(2)
convertquestion=input("Is your amps in milaamps?")
time.sleep(2)
if convertquestion=="yes" or "Yes":
step1=int(input("How many milaaps do you have?"))
step2=step1*.001
amps=step2
time.sleep(2)
forwardvolt=float((input("What is your forward voltage?"))
step_1=powersource-forwardvolt
step_2=step_1/amps
time.sleep(2)
print("You will need a resister value of:", step_2)
else:
firststep=int(input("How many amps do you have?"))
time.sleep(2)
secondstep=float(input("What is your forward voltage?"))
time.sleep(2)
thirdstep=powersource-secondstep
forthstep=thirdstep/firststep
print("You will need a resister value of:", forthstep)
您在第 14 行多了一个括号。将其更改为:
forwardvolt=float(input("What is your forward voltage?"))
我正在尝试创建电阻计算器程序,但出现语法错误。
print("Welcome to resistance calculator!!!")
import time
import math
time.sleep(2)
powersource=int(input("How many volts is your battery?"))
time.sleep(2)
convertquestion=input("Is your amps in milaamps?")
time.sleep(2)
if convertquestion=="yes" or "Yes":
step1=int(input("How many milaaps do you have?"))
step2=step1*.001
amps=step2
time.sleep(2)
forwardvolt=float((input("What is your forward voltage?"))
step_1=powersource-forwardvolt
step_2=step_1/amps
time.sleep(2)
print("You will need a resister value of:", step_2)
else:
firststep=int(input("How many amps do you have?"))
time.sleep(2)
secondstep=float(input("What is your forward voltage?"))
time.sleep(2)
thirdstep=powersource-secondstep
forthstep=thirdstep/firststep
print("You will need a resister value of:", forthstep)
您在第 14 行多了一个括号。将其更改为:
forwardvolt=float(input("What is your forward voltage?"))