Nov-20-2021, 02:06 AM
(This post was last modified: Nov-20-2021, 01:11 PM by Yoriz.
Edit Reason: Added code tags
)
Hi,
I have started learning python this week and am trying to write a simple script. I wish to use a function to create two user defined points A and B, each with two coordinates (x, y). I then want to use another function to add the coordinates together (x1+x2, y1+y2)
Here is what i have...
I have started learning python this week and am trying to write a simple script. I wish to use a function to create two user defined points A and B, each with two coordinates (x, y). I then want to use another function to add the coordinates together (x1+x2, y1+y2)
Here is what i have...
def createPoint(x,y):
return [x,y]
def additionAB (x1, x2, y1, y2):
c = x1 + x2, y1 + y2
return c;
x1 = input ('Enter a value x of point a')
y1 = input ('Enter a value y of point a')
x2 = input ('Enter a value x of point b')
y2 = input ('Enter a value y of point b')
print (c)As I'm new here I have no idea what has gone wrong. I wish to keep it as simple as possible and easy to understand. Any help would be greatly appreciated! Thanks in advance
