## Describing a code

This is the place for queries that don't fit in any of the other categories.

### Describing a code

I have a code produced but I was wondering how to describe each line of the code.

Code: Select all
`class myCoord:    def __init__(self, a, b):        self.x = a        self.y = bclass Line:    def __init__(self, myCoord1, myCoord2):        self.p1 = myCoord1        self.p2 = myCoord2    def calcLine(self):        m = (self.p2.y - self.p1.y) / (self.p2.x - self.p1.x)        c =(self.p1.y - (m*self.p1.x))        if c>0:            return('y=' + str(m) + 'x+' + str(c))        if c<=0:            return('y=' + str(m) + 'x' + str(c))c2y = int(input('Enter the first coordinate y2 axis value:'))c1y = int(input('Enter the first coordinate y axis value:'))c2x = int(input('Enter the first coordinate x2 axis value:'))c1x = int(input('Enter the first coordinate x axis value:'))myCoord1 = myCoord(c2y, c1y)myCoord2 = myCoord(c2x, c1x)line = Line(myCoord1, myCoord2)value = line.calcLine()print(value)`
Last edited by micseydel on Thu Jan 23, 2014 3:52 am, edited 1 time in total.
Reason: Locked OP.
ProDin

Posts: 4
Joined: Thu Jan 23, 2014 2:54 am

### Re: Describing a code

What do you mean "describe"? Is this a school assignment that you can post the exact wording to?
Due to the reasons discussed here we will be moving to python-forum.io on October 1, 2016.

This forum will be locked down and no one will be able to post/edit/create threads, etc. here from thereafter. Please create an account at the new site to continue discussion.

micseydel

Posts: 3000
Joined: Tue Feb 12, 2013 2:18 am
Location: Mountain View, CA

### Re: Describing a code

Thank you for your answer. What I mean by 'describe' is just basically say what each line of the code does. And no its not a school assignment therefore it doesnt have to be exact wording to
ProDin

Posts: 4
Joined: Thu Jan 23, 2014 2:54 am

### Re: Describing a code

A line-by-line description of this code would miss the point of much of it. It uses classes, which are a way to implement object-oriented programming, a high-level way of thinking that narrow focus on single lines wouldn't be adequate for capturing at the level a human is meant to understand the code.

So my question for you is: what do you know of programming? Why are you asking about this piece of code in particular? I think it would be best if you tried to describe the code yourself, and we filled in any gaps or provide any corrections. This will help us understand what we ought to be describing to you, since an absolute beginner programmer certainly would need the line-by-line for learning programming (and Python), but to do so on this code would be very, very confusing. This is the kind of code meant to be understood once you can handle individual lines by yourself.

If you do know zero programming, I would suggest you start here.
Due to the reasons discussed here we will be moving to python-forum.io on October 1, 2016.

This forum will be locked down and no one will be able to post/edit/create threads, etc. here from thereafter. Please create an account at the new site to continue discussion.

micseydel

Posts: 3000
Joined: Tue Feb 12, 2013 2:18 am
Location: Mountain View, CA

Return to General Coding Help

### Who is online

Users browsing this forum: No registered users and 2 guests