For some reason, when I run
import sys
from fractions import Fraction
for i, j in zip(["a","b","c","d","e","f"], range(1,6)):
eval("{0} = int(sys.argv[{1}])".format(i, j))
if a*d != c*b:
x = (e*d-b*f)/(a*d-c*b)
y = (a*f-c*e)/(a*d-c*b)
print "x = ", x , ", y = ", y
elif e*d-b*f == 0 and a*f-e*c == 0:
print "Infinite solutions"
print "Slope = ", Fraction(-a,b), ", Y-Intercept = ", Fraction(e,b)
else:
print "No solution"
using python2 py.py 1 3 3 9 5 15, it gives me the following error
Traceback (most recent call last):
File "py.py", line 4, in <module>
eval("{0} = int(sys.argv[{1}])".format(i, j))
File "<string>", line 1
a = int(sys.argv[1])
^
SyntaxError: invalid syntax
Any ideas as to why this is happening? I'm sure this is the correct syntax, but maybe eval messed it up?
source
share