2016-07-08 39 views
-3

我想創建一個阻力計算器程序,但我得到一個語法錯誤。。試圖查找它,但沒有幫助

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) 
+2

有什麼語法錯誤? –

+1

你得到的語法錯誤是什麼,以及你得到的是哪一行?您可以在您面前的屏幕上獲得該信息。你絕對沒有理由不把它包含在你的問題中。您要求我們幫助您解決**您的問題** - 向我們提供您可用的信息,以幫助我們爲您提供幫助。特別是當你不得不做任何事情,因爲它在你的眼前,在你的屏幕上,它可以很容易地複製和粘貼到你的問題。 –

+0

丟失了圓括號,你的'if'語句也是錯誤的。 – yurib

回答

0

你的線有一個額外的括號14.更改它以這樣的:

forwardvolt=float(input("What is your forward voltage?")) 
+0

謝謝。我沒有看到額外的一個。簡單的修復感謝天謝。 –

+0

因此,我對這個網站很陌生,我的程序現在可以工作,我該如何關閉這個線程,或者我只是離開它? –

+0

哦,我感覺很傻。 XD。 –