Angry face in Python

  Рет қаралды 19

Roberto GS

Roberto GS

Күн бұрын

Hey there, future coders! Today, we’re going to have a blast creating an angry face using Python’s turtle module. By the end of this video, you’ll have a cool drawing and a taste of coding fun! I made this video intended for those young people who want to have tons of fun while getting started in writing some code and hopefully get you guys interested in signing up in computer science courses in the future.
This instruction set is going to be about us drawing an angry face in python. First, we need python downloaded in our computer, so we can follow the next steps.
Step number one is like getting our pen out of our pockets in real life, so we need to import a turtle in Python which is going to be like our pen. We do this by writing:
Import turtle
Step number two is going to be creating a screen to draw on in python by writing the following code:
screen = turtle.Screen()
screen.bgcolor("white")
Step number three is going to be us creating our turtle object that will help us draw by implementing this code
pen = turtle.Turtle()
pen.speed(50)
Note that we have implemented a speed of 50 to the movement of our turtle.
Step number four is going to be writing a definition that will help us later with the creation of circles like face and eyes with the following code
def draw_circle(color, radius, x, y):
pen.penup()
pen.color(color)
pen.fillcolor(color)
pen.goto(x, y)
pen.pendown()
pen.begin_fill()
pen.circle(radius)
pen.end_fill()
You see that we end up using pen up and pen down to signal when we are going to move freely in the screen without drawing and when we are going to move and draw in our screen.
Step number five is to draw the face with the help of this same definition. Note that we have the color, radius of our circle, and the position of our pen signaled in the parameters here:
draw_circle("yellow", 100, 0, -100)
Step number six will be to draw the eyes by using the same method and just changing the parameters.
draw_circle("white", 15, -35, 20)
draw_circle("white", 15, 35, 20)
draw_circle("black", 7, -35, 20)
draw_circle("black", 7, 35, 20)
Then we go into drawing our eyebrows for our seventh step with the help of moving our pen down and up when we move so we do not mess up our craft
pen.penup()
pen.goto(-55, 70)
pen.pendown()
pen.width(5)
pen.goto(-15, 50)
pen.penup()
pen.goto(55, 70)
pen.pendown()
pen.goto(15, 50)
8th Step: draw the mouth with these same functions.
pen.penup()
pen.goto(-40, -20)
pen.pendown()
pen.right(90)
pen.circle(40, 180)
9th Step: Let’s hide the pen so we can see our drawing clearly.
pen.hideturtle()
Finish Up: Keep the window open to admire your work!
turtle.done()
Congratulations! You created a yellow angry face, and while having fun implementing this code and drawing it, you learned how to implement some methods and used some others already defined. If you have any questions, you should go back and see the code again. Thank you for watching!

Пікірлер
How to Draw Circles, Rectangles and Lines in Kivy for Python!
16:35
LeMaster Tech
Рет қаралды 1,1 М.
Q55
0:10
Jim joel
Рет қаралды 5
the balloon deflated while it was flying #tiktok
00:19
Анастасия Тарасова
Рет қаралды 10 МЛН
Who’s the Real Dad Doll Squid? Can You Guess in 60 Seconds? | Roblox 3D
00:34
SISTER EXPOSED MY MAGIC @Whoispelagheya
00:45
MasomkaMagic
Рет қаралды 13 МЛН
Arithmetic Operator in Python
10:00
Navi James
Рет қаралды 5
python NUMBER GEN!!!!
3:51
deckyhax
Рет қаралды 4
Chimera Linux Clean Up Old Kernels
3:03
Den4ikRus
Рет қаралды 56
2-2 Boolean Operators
4:04
AI Code 101
Рет қаралды 7
Convert AutoCAD drawing to a Python Code!
0:30
Ahmed Kullab
Рет қаралды 640
JS Flat Array implementation
4:54
Mandeep Singh
Рет қаралды 48
12 de octubre de 2024
0:16
Roberto GS
Рет қаралды 511
the balloon deflated while it was flying #tiktok
00:19
Анастасия Тарасова
Рет қаралды 10 МЛН