Python Forum

Full Version: Code test
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I just started learning this, i noticed in Finnish language it had lot of things i could not make sense of it, Changed to English and it works better.

I am asked to produce this:


The Turtle's File Exploration VentureĀ¶
This assignment continues our adventures to drawing things with Turtle. This time we're using a real code file
instead of writing instructions one by one into the Python console
. Start by opening your text editor and plopping the following line into it:

from turtle import *

The previous commands are still available. In addition, there's a new one you have to use.

done() # leaves the Turtle window open after the code has finished executing;
# without this the window disappears as soon as the drawing is ready

When executed, the code should draw a 45 degrees tilted square like the one below
dis box is sooo twisted
Hints

Submit your files here:
You have previously answered this task incorrectly.

I did the code, i get it exactly right but this time instead of copying the code it asks for a file.
I save to a file and after try to load it to here so it can check, it does not work at all. I use notepad++ and save it for .py


My code:
from turtle import *
    color('red')
    begin_fill()
    right(45)
    forward (100)
    right(90)
    forward (100)
    right(90)
    forward (100)
    right(90)
    forward (100)
    right(90)
    end_fill()
I think the code is correct, i have issue now that i cannot pass that verification because when i save it to a file and then try to load in there, it does not work.
In CMD (Python), I get it to work everytime.

What do i do wrong?

These are the codes in the instructions that are available:

forward(x) # makes the turtle move forward x pixels, e.g. forward(42)
left(a) # makes a left turn of a degrees, where a is an integer, e.g.. left(40)
right(a) # makes a right turn of a degrees, where a is an integer, e.g.. right(40)
color© # sets color. c is a color value. In this exercise, you can use basic values such as "red", "yellow", "blue", e.g. color("red")
begin_fill() # begins a fill; any lines drawn after this are treated as boundaries for the fill
end_fill() # stops a fill; this command indicates that we're happy with our boundaries, and it's ok to pour the selected color (by the color command) inside
reset() # if you make a mistake, you can use this command to clear everything and return the Turtle to its origin.
done() # leaves the Turtle window open after the code has finished executing;
# without this the window disappears as soon as the drawing is ready
The code after the import is incorrectly indented but that could just be the way you have posted it.
It asks that done() is used at the end
Sorry forgot that, i had it before, just tried different things because it does not work.

And now it works.

I had this typo :(

color("red") and while i found it out and fixed it, after forgot that close()

Now it passed, Drove me nuts. Thanks mate, Appreciate your help!