我想創建一個阻力計算器程序,但我得到一個語法錯誤。。試圖查找它,但沒有幫助
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)
有什麼語法錯誤? –
你得到的語法錯誤是什麼,以及你得到的是哪一行?您可以在您面前的屏幕上獲得該信息。你絕對沒有理由不把它包含在你的問題中。您要求我們幫助您解決**您的問題** - 向我們提供您可用的信息,以幫助我們爲您提供幫助。特別是當你不得不做任何事情,因爲它在你的眼前,在你的屏幕上,它可以很容易地複製和粘貼到你的問題。 –
丟失了圓括號,你的'if'語句也是錯誤的。 – yurib