Coding Randomly Generated Color Bubbles in Python

preview_player
Показать описание
Check it out as we use Python to generate randomly colored, and sized, bubbles in Python.
Рекомендации по теме
Комментарии
Автор

For everyone, who is too lazy to write the text:
import random
from turtle import *
setup()

t = Turtle()

colors = ["blue", "red", "green", "purple", "yellow", "orange"]

t.up()
t.speed(0)

while True:

x = random.randint(-300, 300)
y = random.randint(-300, 300)
circle_size = random.randint(1, 300)
circle_color = random.choice(colors)
t.goto(x, y)
t.down()
t.color(circle_color)
t.begin_fill()
t.circle(circle_size)
t.end_fill()
t.up()

laserente
Автор

hey there i am writing a code that needs to generate random circles so i can move to them. i have written the code for controls and the bubble generator but it just doesn't respond? any ideas?

mof
Автор

Thank you soooo much! It helped me alot for my Today's HomeWork! Thank you! <3

Ara_Ara_Kocho
Автор

Hey, I'd like to create a function that takes an integer "a" as argument and will plot "a" element in a graph, I would also add up a speed to them do u have an idea how could I do that ?

karljoyeux
Автор

Sir, I am working on Spyder, when I run my code then the error occur
:setup not defined
What I do
How can I define

saurabhtaroliya
Автор

i know i am 4 years late, but what if i wanted the turtle to only draw 50 circles? how do i do that?

horcruxx
Автор

im trying to fill in the circle with random colors how would i do that?


Here is the code, i have a list but idk how to incorporate it into the random colors

Code

import turtle
import random

t = turtle.Turtle()
pg = turtle.Screen()

colors = ["red", "blue", "green", "yellow", "black", "grey"]

def mouse_clicked(x, y):
print("Mouse has been clicked")
r = random.randint(1, 100)
t.penup()
print(x, y)
t.goto(x, y)
t.pendown()
t.circle(r)

pg.onclick(mouse_clicked)

#pg.onscreenclick()
pg.listen()
pg.mainloop()

SoHalalG
Автор

I'm getting an error
object of type "int" has no len()

xenon
Автор

Mem in python have rgb () right?but l can't code random color => how l can do that?

xathien