Coding in Python
Online programming environment for kids
Data is being received from the server.

COMMAND USAGE EXAMPLE
pendown(), pd() pd()
The spaceship has the pen down (active) and draws a line in its trail.
penup(), pu() pu()
The spaceship has the pen up (inactive) and does not draw a line in its trail.
pensize(value), width(value) pensize(25)
Sets the pen tip size to value pixels.
pencolor(color) pencolor("#ff00ff")
Sets the drawing color. The color parameter can be specified using standard names or HEX values (internet format). Examples:
pencolor('red')
pencolor("#ff0000")
Standard colors: "black" (
), "blue" (
), "lime" (
), "cyan" (
), "red" (
), "magenta" (
),
"yellow" (
), "white" (
), "brown" (
), "tan" (
), "green" (
), "aquamarine" (
), "salmon" (
),
"purple" (
), "orange" (
), "gray" (
).
fillcolor(color) fillcolor("yellow")
Sets the fill color (default is black). The color parameter can be a standard name or a HEX code (internet format).
Examples:
fillcolor("red")
fillcolor("#ff0000")
color(c_drawing[,c_filling]) color("red","green")
We can modify both the drawing and filling colors simultaneously. If the c_filling parameter is missing, the color described by c_drawing is used for both attributes.
COMMAND EXAMPLE OF USE
stamp() stamp()
Draws a copy of the turtle's shape on the canvas at the current position, like a stamp.
begin_fill() begin_fill()
Starts a new path that describes a geometric shape (a polygon).
end_fill() end_fill()
Closes the current path and fills the geometric shape with the fill color (see fillcolor()).

Example. The following program draws a green square. The fill color is set first, then the path is started with begin_fill():
from turtle import *
fillcolor('green')
begin_fill()
for i in range(4):
    forward(150)
    right(90)
end_fill()

The desired geometric shape is drawn, and the end_fill() command closes the path and fills it with green.
fill() print(fill()) ; if (fill()) ...
The function returns a boolean value based on the fill mode state: true (True) or false (False), useful in some slightly more complex programs.
dot() dot()
Draws a dot at the current position. The function is very useful if you want to use it in combination with penup(), drawing only certain important points during the turtle's movement.

Example. Below we draw only the corners of a square:
from turtle import *
pensize(10)
pu()
for i in range(4):
    dot()
    fd(100)
    left(90)
pu()
back(50)
circle(radius, angle, steps) circle(50,360,100)
A circle is characterized by radius, which is the distance from the center to any point on it. Then, you need to understand that a circle is made up of steps points. You can draw a full circle using angle value of 360 degrees or just a part of it, specifically an arc, by specifying a smaller angle accordingly. The larger the steps, the finer the drawing of the geometric shape.
The magic of geometry. When steps = 4, a square (like a diamond) is drawn, and for steps = 5, a pentagon. Choosing steps = 6 gives us a hexagon, and so on. The larger the steps parameter value, the closer the regular polygon approximates the circle it inscribes!

Examples. Test the code below to understand better:
from turtle import *
#triangle, square, ...
for i in range(6):
    circle(100,360,i+3)
pencolor("yellow")
#the final circle
circle(100,360,100)

write(message, move, alignment, font) write("Hello")
Writes the text from message starting from the current position. The move parameter is boolean (True / False) and allows the turtle to move or not while the message is being drawn. The alignment parameter can take values "left", "center", or "right". The text style is entered as a tuple of data: (font, size, font_style).

Example. Below is text written without moving the turtle (False), aligned to the left and with a specific style set:
from turtle import *
fillcolor("yellow")
write("Hello on Mars!", False, "left", ("Verdana","32px","bold"))

Notes
• The font_style parameter can be "normal", "italic", or "bold".
• To move the turtle without drawing a line, you can of course use penup() before the write() command, and then return with pendown():

from turtle import *
fillcolor("yellow")
penup()
write("Hello on Mars!", True, "left", ("Verdana","32px","bold"))
pendown()


• Only the text as message is a mandatory parameter, while the rest are optional. Play with different text style values! For example, common standard font names are: "Tahoma", "Verdana", "Arial", "Calibri", etc.
COMMAND EXAMPLE OF USE
variable_name = clone() clone1 = clone()
A new variable, accessible through variable_name, will hold a new graphic object (an identical spaceship) that can be controlled using the Python programming language. The position on the screen and other parameters will also be identical with all attributes of the "parent" ship. You can create one clone, two ... or as many as you want!
Note! The "parent" ship can still be controlled with direct commands like fd(80), but clone1 in the example will receive instructions such as clone1.fd(50) because they are different objects on the screen, and addressing must be done accordingly!
Important observation! Python is an interpreter and executes instructions sequentially, that is, one after the other. Thus, graphic objects on the screen will perform animations alternately depending on the program you create!
Example. Test the code below:

from turtle import *
pencolor("#671915")
fd(100)
clone1 = clone()
clone1.bk(200);
clone1.circle(40,360,4)
clone2 = clone()
clone2.fillcolor("white")
clone2.setpos(-200,200)
clone2.write("Super cool on Mars!",False,"left",("Verdana","24px","bold"))
clone2.pu(); clone2.bk(50)
fd(90); circle(70) #return to the "parent" ship
variable_name = Turtle() ship2 = Turtle()
A new variable, accessible through variable_name, will hold a new graphic object (a new spaceship). Unlike clone(), this function creates a new object with default parameters starting from coordinates (0,0).
Example. Test the code below:

from turtle import *
#parent ship
color("yellow")
right(45)
back(100)
circle(20)
#a new ship created
ship2 = Turtle()
ship2.fd(100)
ship2.left(45)
ship2.fd(100)
ship2.circle(20)


A little trick. To simulate the simultaneous movement of two spaceships, we can move them with a small step (e.g., 1 pixel) alternately, as in the example below:

from turtle import *
#main ship
color("yellow"); speed(0)
#second ship
ship2 = Turtle()
ship2.color("green")
ship2.fd(30)
ship2.speed(0)
for i in range(120):
lt(3); fd(1)
ship2.rt(3); ship2.fd(1)

The speed of the two ships in this case still decreases significantly...
ABOUT PYTHON 3
The Python 3 language is widely used today, being very popular, easy to learn, and user-friendly. Unlike other programming languages, Python 3 is quickly understood, even from the beginning. Study the first lessons offered for free at masterpy.com to learn more about Python!

You have access to this course from anywhere and on any device you want, as the Python 3 programming environment is integrated and optimized for mobile. You do not need to install any additional software, just learn.

The Python language is free, open-source, and strongly object-oriented.
INFORMATION FOR TEACHERS
The interactive online course follows the curriculum approved by the Ministry of Education and can be used in any educational cycle as an introduction to Python 3 programming. The information presented is optimized in size and emphasizes frequent interaction with the user. The assessment of exercises and problems proposed in this course is in real-time and each includes interactive feedback.

The platform is modern, online, and kids can create cool programs in Python 3 from any device, anywhere, and anytime.

The graphical interface is intuitive, common typing errors are immediately prevented, and students can easily experiment with programming!

Suitable for any student who can read and write! At any age, students can learn mathematical and computational concepts in Python, along with teachers or parents - it enhances their creative thinking, optimal problem-solving, logic, and collaboration. However, the Python environment is powerful! It can run recursive procedures, as well as many other complex programs!
INFORMATION FOR PARENTS
Starting from the middle school level, students learn programming at school. Unlike other languages, Python 3 has a simplified syntax to write code much more easily! It is perfect for beginners, friendly, and future-proof. Modern students study Python 3!

Study the lessons and theoretical elements, analyze solved and proposed problems, complete multiple-choice tests (pay attention to grades) ... and earn the Junior Programmer Diploma. 😀 Join the Pythonists community now!
ABOUT TURTLE GRAPHICS
Turtle Graphics is an educational programming language created in 1967 by Daniel G. Bobrow, Wally Feurzeig, Seymour Papert, and Cynthia Solomon. Today, it is known as the Turtle Graphics language (based on its English name, Turtle Graphics), because using certain commands, it or a robot draws graphic elements on the screen or on a surface:



Seymour Papert, a professor at the Artificial Intelligence Laboratory at M.I.T., invented the Turtle Graphics concept in the 1970s:
... the turtle. You can think of it as a graphic tool. Imagine looking at a computer monitor. There you see a small turtle that moves when you input commands using its language, leaving a line behind as it moves. The command forward(50) will make the turtle move straight ahead a certain distance. forward(100) will make it move in the same direction twice as far. Soon, you will grasp the idea that numbers represent the distance it moves; they can be considered as steps. Now, if you want it to move in a different direction, you enter a command like right(90). It will stay in the same place but turn east if it was initially facing north. With this knowledge, you will be able to draw a circle or a rectangle easily. And if this is easy for you, you can think about drawing a circle or try to draw a spiral.

At some point, you will find yourself in difficulty; when you reach that point, here's a little advice: Put yourself in the turtle's place. Imagine moving along the path of that square, circle, or spiral ... or whatever it may be
.”

Turtle Graphics in Python 3 can be considered an engaging way to introduce programming concepts to students. By simply writing a few small instructions, students can create interesting graphical programs. Programs are run in an animated manner, and the effect is immediately visible on the screen. As you have seen, recursive subroutines can also be run, as well as many other complex programs!
THE TURTLE MODULE IN PYTHON 3
The Python 3 language includes the turtle module in its standard library, so you just need to include it in your program and then run an example, as shown above in the editor!

Consider the workspace as a canvas where you can draw whatever you want. Imagine the Turtle has a pen attached, and as it moves, it leaves a straight or curved line behind it. Your role is just to write the right program! Initially, the Turtle is in the center of the workspace (known in English as turtle space).

Here on Mars, we call the graphical turtle a "spaceship"!

NOTE. We can use only a subset of the functions and commands in Python 3 through the browser, and these are described in detail on the page. The online programming environment is a simulation created in another web programming language called JavaScript, and the animation speed is significantly superior to native Python programs!
DEMO PROGRAMS IN PYTHON
See what you can do graphically with Python using some cool examples!