# Mercy Tinker

@MercyMuchangi
shared a Post
3 years ago
How can one draw a birthday cake using a function, variables and a loop
How can I change the color of the layers of the cake
Python (with Turtle)
PattanAhmed
@MercyMuchangi Hi, From your code, you may get something like this Code:- import turtle import random t = turtle.Turtle() x = random.randint(10, 200) y = random.randint(20, 100) for i in ['red', 'green', 'yellow', 'blue']: t.color(i) t.forward(x) t.left(90) t.forward(y) If you want range function too, I think it's not possible as the output of this code is not like your code output. Code with range:- import turtle import random t = turtle.Turtle() x = random.randint(10, 200) y = ran3 years ago
DEMONul1234
t = turtle.Pen() t.pencolor('Red') t.speed(30) for i in range(100): t.forward(100) t.left(91) It creates a circle, remember to use .pencolor("insert color name here") to add colors3 years ago
MercyMuchangi
shared a Post
3 years ago
How can I draw a rectangle using a for loop
Python (with Turtle)
Amani21
what is this???!!!!!!1 year ago
PattanAhmed
@MercyMuchangi Hi, Check this Picture in which it shows you how to make a rectangle using a For Loop for loop turtle Hope this helps Please mark my answer if this helps*3 years ago
gibbsfreenergy
import pygame from pygame.locals import * from sys import exit from random import * pygame.init() screen = pygame.display.set_mode((640, 480), 0,32) while True: for event in pygame.event.get(): if event.type == QUIT: exit() screen.lock() for count in range(10): random_color = (randint(0,255), randint(0,255), randint(0,255)) random_pos = (randint(0,639), randint(0,479)) random_size = (639-randint(random_pos[0], 639), 479-randint(random_pos3 years ago