# e = volt = r * i, p / i, sqrt(p * r) # i = amp = sqrt(p / r), p / e, e / r # r = ohm = e / i, e**2 / p, p / i**2 # p = watt = e**2 / r, i**2 * r, e * i import math print "How many volts?" e = raw_input("") #print e, " volts" print "How many amps?" i = raw_input("") #print i, " amps" print "How many ohms?" r = raw_input("") #print r, " ohms" print "How many watts?" p = raw_input("") #print p, " watts" # convert anything entered to int... may need float e = int(e) i = int(i) r = int(r) p = int(p) # find the value of volts def volts(e, i, r, p): if r > 0 and i > 0: e = r * i return e else: if r > 0 and p > 0: e = math.sqrt(p * r) return e #find the value of amps def amps(e, i, r, p): if e > 0 and r > 0: i = e / r return i else: if p > 0 and r > 0: i = math.sqrt(p / r) return i # find value of ohms def ohms(e, i, r, p): if e > 0 and i > 0: r = e * i return r else: if p > 0 and i > 0: r = p / i**2 return r # find value of watts def watt(e, i, r, p): if e > 0 and r > 0: p = e**2 / r return p else: if i> 0 and r > 0: p = i**2 * r return p e = volts(e, i, r, p) i = amps(e, i, r, p) print e, "volts..." print i, "amps..." print r, "ohms..." print p, "watts..."
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question