Skip to content
Sign UpLog In
Profile icon

Mercy Tinker

@MercyMuchangi
Repls
Community
MercyMuchangi
MercyMuchangi
shared a Post
2 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
revision part 2
Python (with Turtle)
PattanAhmed
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 = ran2 years ago
DEMONul1234
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 colors2 years ago
MercyMuchangi
MercyMuchangi
shared a Post
2 years ago
How can I draw a rectangle using a for loop
revision 2
Python (with Turtle)
Amani21
Amani21
what is this???!!!!!!5 months ago
PattanAhmed
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*2 years ago
gibbsfreenergy
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)) randomsize = (639-randint(randompos[0], 639), 479-randint(random_pos[2 years ago