samedi 12 novembre 2022

How to create a function which tells how far Turtle has travelled in Python?

import math
import turtle
import random

# Starting Code
def moveTurtle():
 for count in range(10):
   choice = move.randint(1,2)
   if (choice==1):
     turtle.forward(move.randint(3, 30))

   elif(choice==2):
     turtle.right(move.randint(1,234))

def testTurtle():
 turtle.forward(100)
 turtle.left(90)
 turtle.forward(100)

moveTurtle()

testTurtle()

def distance(x,y):

I am new to Python and I'm not quite sure how to write a function that returns the turtle's total distance from random. The function needs to return the distance back to the main program and print it out. Can someone help?




Aucun commentaire:

Enregistrer un commentaire