lundi 19 août 2019

How do you make a random number gen between 1 and 20 in turtle

I have a code for a random colour chooser but not a random NUMBER. I need it to choose a random number 15 times each between 5 and 20, but the twist is that the total of all 15 numbers has to be equal to 227

I have a code for a random colour generator, but I can't figure out how to generate numbers and how to get a total of 227

import turtle
import random
turtle.bgcolor("black")
t = turtle.Pen()

t.width(4)
colours = ["yellow", "orange", "red"]
for i in range(60):
    t.pencolor(colours[random.randint(0,2)])
    t.forward(100)
    t.back(100)
    t.left(6)




Aucun commentaire:

Enregistrer un commentaire