• Log in or sign up for an account here: https://www.sythe.org/login

Python 2

asdasd123

Forum Addict
Joined
Feb 2, 2012
Sythe Gold
0
Messages
417
Hey I posted before and now I'm absolutely stuck on a question
Please do it all I have no idea how to do it :s

# Join the dots
#
# This exercise gives you practice at both turtle graphics and
# using lists. It is strongly recommended that you complete
# the "Starry, starry night" exercise before attempting this
# one.


# THE PROBLEM
#
# You are required to draw 20 (or more) randomly-positioned dots
# on the screen and then draw a line connecting them together in
# the same order that they were drawn. Draw the dots and the
# connecting line in different colours. NB: You cannot start
# drawing the line until AFTER you've finished drawing all the
# dots. This means you'll need to find a way of remembering
# where all the dots are and the order in which they appeared.
#
# HINT: A list is a good way of remembering a sequence of
# numbers!

from turtle import *
from random import randint
# speed("fastest")


# Problem-solving strategy:
#
# 1. Draw the screen
# 2. Create list(s) to record the coordinates of the dots
# 3. Draw the dots. For each one:
# a. Choose a random position on the screen
# b. Move to the chosen position and draw a dot
# c. Record the position of the dot in your list(s)
# 4. Draw the line
# a. Change to an appropriate pen color and size
# b. Go to the position of the first dot, without drawing
# c. For each position recorded in the list(s), go to that
# position, drawing as you go
# 5. Exit gracefully by unlocking the screen
 
Runescape Gamblingrunescape gambling
Back
Top