# Okay learning python is somewhat hard.

Lamonte Harris pyth0nc0d3r at gmail.com
Tue Aug 28 23:04:39 CEST 2007

```Since I can't really focus on PROJECTS[since I don't know much python I
can't do any projects because all my projects are BIG], So I decided to work
on some problems I've gotten from school from started geometry, So I
attempted to make a script to get the midpoint of a line segment using the
formula giving:

[1 and 2 are subscripts]

X1 + X2
----------- = mid pt. (x)
2

Y1 + Y2
----------- = mid pt. (y)
2

So i tried coding the following script.

#MIDPOINT OF A LINE
class midpoint:
def __init__(self,x1,x2,y1,y2):
self.x1 = x1
self.x2 = x2
self.y1 = y1
self.y2 = y2
self.dictionary = {'x' : '','y' : ''}
self.calculate_mid_point()
def calculate_mid_point(self):
X = self.x1 + self.x2
X = X/2
self.dictionary['x'] = X
Y = self.y1 + self.y2
Y = Y/2
self.dictionary['y'] = Y
c_x = -2
c_y = -2
d_x = 4
d_y = 3
midpoint_ = midpoint(c_x,d_x,c_y,d_y)
print midpoint_.dictionary

It works and all, but I can't get the fraction or decimal from the output :S

Output:
{'y': 0, 'x': 1}

On my paper the real output is:
x = 1
y = 1/2
-------------- next part --------------
An HTML attachment was scrubbed...