Untitled
import turtle # Set up the screen screen = turtle.Screen() screen.bgcolor("lightblue") screen.title("Happy 19th Birthday!") # Function to draw a circle def draw_circle(x, y, radius, color): turtle.penup() turtle.goto(x, y - radius) turtle.pendown() turtle.fillcolor(color) turtle.begin_fill() turtle.circle(radius) turtle.end_fill() # Function to draw a rectangle def draw_rectangle(x, y, width, height, color): turtle.penup() turtle.goto(x, y) turtle.pendown() turtle.fillcolor(color) turtle.begin_fill() for _ in range(2): turtle.forward(width) turtle.left(90) turtle.forward(height) turtle.left(90) turtle.end_fill() # Function to draw the cat's head def draw_cat_head(): # Draw the head draw_circle(-50, 100, 50, "white") # Draw the left ear draw_rectangle(-90, 150, 40, 60, "white") # Draw the right ear draw_rectangle(-10, 150, 40, 60, "white") # Eyes draw_circle(-70, 120, 8, "black") draw_circle(-30, 120, 8, "black") # Nose draw_circle(-50, 100, 5, "pink") # Function to draw the cat's body def draw_cat_body(): # Draw the dress draw_rectangle(-90, 50, 80, -100, "pink") # Function to draw the cake def draw_cake(): # Cake base draw_rectangle(50, 50, 40, 30, "brown") # Candle turtle.penup() turtle.goto(70, 80) turtle.pendown() turtle.color("yellow") turtle.setheading(90) turtle.forward(20) # Function to draw the balloon def draw_balloon(): draw_circle(100, 200, 30, "red") # String for the balloon turtle.penup() turtle.goto(100, 170) turtle.pendown() turtle.setheading(-90) turtle.forward(100) # Main drawing turtle.speed(3) draw_cat_head() draw_cat_body() draw_cake() draw_balloon() # Write "Happy 19th Birthday!" turtle.penup() turtle.goto(-200, -50) turtle.color("purple") turtle.write("Happy 19th Birthday!", font=("Arial", 24, "bold")) # Hide the turtle turtle.hideturtle() # Keep the window open screen.mainloop()
Leave a Comment