[Tutor] Livewires
Tonu Mikk
tmikk at umn.edu
Mon Sep 10 17:33:47 CEST 2007
Hi Sacha, I am very much a beginner to Python myself, but I tried my
hand on the Livewires modules. Here is how I solved the challenge.
from livewires import *
begin_graphics()
allow_moveables()
x=0
y=0
c = circle(x, y,5)
while x < 640:
x=x+5
y=y+3.822
move_to (c, x, y)
time.sleep(0.1)
Tonu
sacha rook wrote:
> Hi all
>
> just learning python really and been using the livewires tutorial /
> worksheets to get some experience.
>
> I have hit an issue which is just my lack of understanding around
> looping concepts and execution.
>
> My issue:
>
> in worksheet 5-robots.pdf attached, page 4 the challenge
>
> "Challenge: Write a loop that makes the circle move smoothly from
> (0,0) to (640,480): in other words, from the bottom left
> to the top right of the screen."
>
> this has got me a bit stumped because its an (x,y) co-ordinate pair
> that I want to update.
> I think in a loop i need to draw a circle, move a circle, remove the
> circle.
>
> I thought I needed to for loops to iterate through two ranges but this
> is wrong, here is my code though!
>
> from livewires import *
> begin_graphics()
>
> allow_moveables()
> x=range(10,640,10)
> y=range(10,480,10)
> for xco in x:
> for yco in y:
> c = circle(xco,yco,5)
> move_to(c, xco,yco)
> # remove_from_screen(c) /*commented this out to see output on
> graphics window */
> end_graphics()
>
> Can anyone look at the worksheet challenge and my poor code and show
> me the error of my ways? :)
> I appreciate it may be my inexperience in program flow/logic which is
> the problem also, I don't my help or suggestion to improve in any area.
> Thanks for your help in advance
> Sacha
>
>
>
> ------------------------------------------------------------------------
> Play Movie Mash-up and win BIG prizes! <https://www.moviemashup.co.uk>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Tutor maillist - Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
More information about the Tutor
mailing list