samedi 15 juin 2019

How to use random to choose colors

I'm trying to make a little program to learn more, but am stuck when it comes to using random.

Here is an example of what I'm going off of https://trinket.io/Python/3338c95430

I've tried using random.randrange, random.choice, random.random with everything for them and it sends an error code saying random doesn't have a function of randrange, choice, or random.

import turtle, math, random, time

wn = turtle.Screen()
wn.bgcolor('grey')
Rocket = turtle.Turtle()
Rocket.speed(0)
Rocket.color('red') ## this is what i want to randomize
rotate=int(90)

def drawCircles(t,size):
    for i in range(15):
        t.circle(size)
        size=size-10
def drawSpecial(t,size,repeat):
    for i in range(repeat):
        drawCircles(t,size)
        t.right(360/repeat)
drawSpecial(Rocket,100,10)

Eventually I would like to implement more randomized processes like the size and placement but for now I'm just focusing on color.




Aucun commentaire:

Enregistrer un commentaire