728x90
반응형

 

 

 

 

 

 

 

11.

import random

myList = []
sum = 0

for i in range(0,100) :
    myValue = random.randint(1,6)
    myList.append(myValue)


for v in myList :
    sum += v

avg = sum/100

print("100번 던진 주사위 값의 평균은 ", avg, " 입니다")

 

 

12.

import turtle
import random

turtleList = []
colorList = ['green', 'blue', 'red', 'magenta', 'orange', 'black']

turtle.shape('turtle')
turtle.screensize(500,500)

for i in range(0,100) :
    color = random.choice(colorList)
    x = random.randint(-250, 250)
    y = random.randint(-250, 250)
    myTurtle = (color, x, y)
    turtleList.append(myTurtle)    

for tup in turtleList :
    turtle.color(tup[0])
    turtle.goto(tup[1],tup[2])
    turtle.stamp()

turtle.done()

 

 

728x90
반응형

+ Recent posts