Jul-02-2018, 03:07 AM
The object of my program is to calculate one side of a triangle using pythagorean theorem. I feel like my code should work, but I keep receiving this error message:
Thank you in advance for your assistance.
Error:Traceback (most recent call last):
File "c:\users\julia\source\repos\Assignment12\Assignment12\Assignment12.py", line 19, in <module>
ipt = int(input("Pythagorean theorem, Enter sides A and B and I will solve for C\n"))
ValueError: invalid literal for int() with base 10: '3 4'
I am not quite sure where to go from here.Thank you in advance for your assistance.
import math def pythag( a, b, c1): if(c1 == 'c') : c = math.sqrt(pow(a, 2) + math.pow(b, 2)) else : c = math.sqrt(pow(a,2) - math.pow(b,2)) return c ipt = int(input("Pythagorean theorem, Enter sides A and B and I will solve for C\n")) a, b = ipt.split(" ") print("Side C is equal to", pythag(a, b,'c')) ipt = int(input("\nNow enter sides B and C and i will solve for A\n")) a, b = ipt.split(' ') print("Side A is equal to", pythag(b, a,'a')) ipt = (input("\nFinally, enter sides A and C and i will solve for B\n")) a, b = ipt.split(' ') print("Side B is equal to", pythag(b, a,'b'))