0

Can someone please help me with the following lines of code, and explain why nothing seems to be happening:

Many thanks,

from turtle import *
import time

def poly( n, N ):
    """ draws n sides of an N-sided regular polygon """
    if n == 0:
        return
    else:
        forward( 50 )   # 50 is hard-coded at the moment...
        left( 360.0/N )
        poly( n-1, N )
        poly( 7, 7)
        return


def chai(size):
    """ our chai function! """
    if (size<50): 
        return
    else:
        forward(size)
        left(90)
        forward(size/2.0)
        right(90)
        right(90)
        forward(size)
        left(90)
        left(90)
        forward(size/2.0)
        right(90)
        backward(size)
        return
1
  • you have defined two functions. What would you expect to happen? Commented Aug 3, 2015 at 12:22

2 Answers 2

1

You need to call your functions. So at the bottom type chai(100) or poly(4, 6) or whatever it is that you want to call. Alternatively you can import these functions in the shell, another file, or wherever you want to call them and run them there.

Sign up to request clarification or add additional context in comments.

Comments

0

You declared functions, but you never called them. It appears to be running fine.

poly(2,3) enter image description here

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.