473,399 Members | 3,919 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

unsupported operand types??

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
1 5631
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

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

Similar topics

6
by: DJ Craig | last post by:
I keep getting this error: Fatal error: Unsupported operand types in /usr/local/etc/httpd/htdocs/djtricities/kat/bpmchart/chart.php on line 58 I've looked for hours for some type of error, and...
3
by: Martin Koekenberg | last post by:
Hello, Ik get the following error when I install a new Python software package such as Zope or PIL. This is what I get whem I 'make' Zope : running build_ext Traceback (most recent call...
3
by: Rakesh | last post by:
In my Python code fragment, I want to write a code fragment such that the minimum element of a tuple is subtracted from all the elements of a given tuple. When I execute the following python...
3
by: yaffa | last post by:
hey folks i get this error: Python interpreter error: unsupported operand type(s) for |: when i run this line of code: for incident in bs('tr', {'bgcolor' : '#eeeeee'} | {'bgcolor' :...
5
by: Arpan | last post by:
I am trying to make a calculator in ASP.NET using VB.NET but certain errors are cropping up. This is a part of the code (please note that the code lines that are bold & in red colour generate the...
3
by: tanusreesen | last post by:
Hi All, I am completely new to python programming language.I was trying to write a program on class.But I am getting this error.Can someone please help me to solve the error I am facing.I...
1
by: Florian Lindner | last post by:
Hello, I get the exception above when trying to use a float as radix and exponent, e.g.: Traceback (most recent call last): File "<stdin>", line 1, in ? TypeError: unsupported operand type(s)...
7
by: somenath | last post by:
Hi All, I am trying to undestand "Type Conversions" from K&R book.I am not able to understand the bellow mentioned text "Conversion rules are more complicated when unsigned operands are...
8
by: Gilbert Fine | last post by:
This is a very strange exception raised from somewhere in our program. I have no idea how this happen. And don't know how to reproduce. It just occurs from time to time. Can anyone give me some...
2
by: Jordan Harry | last post by:
I'm trying to write a simple program to calculate permutations. I created a file called "mod.py" and put the following in it: def factorial(n): a = n b = n while a>0 and b>1: n = (n)*(b-1)...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.