0% found this document useful (0 votes)
45 views3 pages

01 Laboratory Exer 1 Group

awdawd

Uploaded by

shaftermine06
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
45 views3 pages

01 Laboratory Exer 1 Group

awdawd

Uploaded by

shaftermine06
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Group

Bermejo, Louis Paolo L.


Prince Roger Reyes
Justin Anonuevo

01 Laboratory Exercise 1
Python’s Turtle

Code:

import turtle

# Set up the screen


ts = turtle.Screen()
ts.bgcolor("white")

# Initialize the turtle


t = turtle.Turtle()
t.speed(3)

# Function to draw a circle with a given color


def draw_circle(turtle, color, radius, x, y):
turtle.penup()
turtle.goto(x, y)
turtle.pendown()
turtle.color(color)
turtle.begin_fill()
turtle.circle(radius)
turtle.end_fill()

# Draw the face


draw_circle(t, "yellow", 100, 0, -100)

# Draw the left eye


draw_circle(t, "white", 20, -40, -20)
draw_circle(t, "black", 10, -40, -10)

# Draw the right eye


draw_circle(t, "white", 20, 40, -20)
draw_circle(t, "black", 10, 40, -10)

# Draw the mouth


t.penup()
t.goto(-40, -60)
t.pendown()
t.right(90)
t.circle(40, 180) # Draw a semi-circle
# Hide the turtle and complete drawing
t.hideturtle()
ts.mainloop()

Explanation:
 Setup: Initialize the screen and turtle.
 Draw a Circle: draw_circle() is a helper function to simplify drawing filled circles.
 Draw the Face: A large yellow circle for the face.
 Draw the Eyes: Two white circles with black circles for pupils.
 Draw the Mouth: A semi-circle to represent a smiling mouth.
 Hide the Turtle: Hide the turtle cursor when done.
Output:

You might also like