def solution(info: str) -> str:
V, A, R = None, None, None
for i in info.split(" "):
l = len(i) - 1
if 'R' in i:
R = float(i[0:l])
elif 'A' in i:
A = float(i[0:l])
elif 'V' in i:
V = float(i[0:l])
else:
raise ValueError("传值格式错误")
if A is None:
return str(round(V / R, 6)) + "A"
elif V is None:
return str(round(A*R, 6)) + "V"
else:
return str(round(V/A, 6)) + "R"
assert solution("2200R 5V") == "0.002273A"
assert solution("0.005A 30V") == "6000.0R"
assert solution("30V 5000R") == "0.006A"
assert solution("0R 0A") == "0.0V"
def solution(info: str) -> str:
s1, s2 = info.split(" ")
a, b = float(s1[:-1]), float(s2[:-1])
if 'V' in info:
if 'V' in s1:
r = a / b
else:
r = b / a
return str(round(r, 6)) + ('A' if 'R' in info else 'R')
else:
return str(round(a*b, 6)) + 'V'
assert solution("2200R 5V") == "0.002273A"
assert solution("0.005A 30V") == "6000.0R"
assert solution("30V 5000R") == "0.006A"
assert solution("0R 0A") == "0.0V"
def solution(info: str) -> str:
list1=info.split(' ')
for i in list1:
if 'A' in i:
A=float(i[0:-1])
elif 'R' in i:
R=float(i[0:-1])
else:
V=float(i[0:-1])
if 'A' not in info:
return str(round(V/R,6))+'A'
if 'V' not in info:
return str(round(A*R,6))+'V'
if 'R' not in info:
return str(round(V/A,6))+'R'
assert solution("2200R 5V") == "0.002273A"
assert solution("0.005A 30V") == "6000.0R"
assert solution("30V 5000R") == "0.006A"
assert solution("0R 0A") == "0.0V"