The last line of the traceback tells you where the problem is:
File "C:UsersmattDownloadsspirograph.py", line 27, in spirograph
spirograph(p-1, x,y) # <--- this is the problem line
TypeError: spirograph() missing 2 required positional arguments: 'x' and 'y'
In your code, the spirograph()
function takes 5 arguments: def spirograph(R,r,p,x,y)
, which are R
, r
, p
, x
, y
. In the line highlighted in the error message, you are only passing in three arguments p-1, x, y
, and since this doesn't match what the function is expecting, Python raises an error.
I also noticed that you are overwriting some of the arguments in the body of the function:
def spirograph(R,r,p,x,y):
R=100 # this will cancel out whatever the user passes in as `R`
r=4 # same here for the value of `r`
t=2*pi
Here is a simple example of what is happening:
>>> def example(a, b, c=100):
... a = 1 # notice here I am assigning 'a'
... b = 2 # and here the value of 'b' is being overwritten
... # The value of c is set to 100 by default
... print(a,b,c)
...
>>> example(4,5) # Here I am passing in 4 for a, and 5 for b
(1, 2, 100) # but notice its not taking any effect
>>> example(9,10,11) # Here I am passing in a value for c
(1, 2, 11)
Since you always want to keep this values as the default, you can either remove these arguments from your function's signature:
def spirograph(p,x,y):
# ... the rest of your code
Or, you can give them some defaults:
def spirograph(p,x,y,R=100,r=4):
# ... the rest of your code
As this is an assigment, the rest is up to you.