By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,969 Members | 2,360 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,969 IT Pros & Developers. It's quick & easy.

unsupported operand types??

P: 1
Expand|Select|Wrap|Line Numbers
  1. line1 = ((0.0, -1.0), (1.0, 1.0), (2.0, 3.0), (3.0, 5.0), (4.0, 7.0), (5.0, 9.0), (6.0, 11.0), (7.0, 13.0), (8.0, 15.0), (9.0, 17.0))
  2. line2 = ((0.0, 2.0), (1.0, 1.0), (2.0, 0.0), (3.0, -1.0), (4.0, -2.0), (5.0, -3.0), (6.0, -3.0), (7.0, -5.0), (8.0, -6.0), (9.0, -7.0))
  3. num1 = str(len(line1))
  4. num2 = str(len(line2))
  5. x1 = str(line1[0][0]-line1[1][0])
  6. y1 = str(line1[0][1]-line1[1][1])
  7. m1 = (y1/x1)
  8. b1 = (y1 - m1*x1)
  9. x2 = str(line2[0][0]-line1[1][0])
  10. y2 = str(line2[0][1]-line1[1][1])
  11. m2 = (y2/x2)
  12. b2 = (y2 - m2*x2)
  13. x3 = ((b2 - b1) / (m1 - m2))
  14. y3 = (m2*x2)
  15. s = "line 1 information = number of points in line: " & num1 \
  16.     + " slope: " & str(m1) & " y intercept: " & str(b1) & \
  17.     "line 2 information = number of points in line: " & num2 & \
  18.     " slope: " & str(m2) & " y intercept: " & str(b2) & \
  19.     " line intersection: (" & str(x3) & "," & str(y3) & ")"
Traceback (most recent call last):
File "C:/Users/owner/Documents/hw16.py", line 7, in <module>
m1 = (y1/x1)
TypeError: unsupported operand type(s) for /: 'str' and 'str'
Apr 22 '10 #1
Share this Question
Share on Google+
1 Reply


P: 1
m1 = (y1/x1)
TypeError: unsupported operand type(s) for /: 'str' and 'str'
You are trying to divide two strings. You must use numbers, so convert to an integer or float before dividing.
Apr 22 '10 #2

Post your reply

Sign in to post your reply or Sign up for a free account.