Gif import turtle wn turtlescreen tturtleturtle

Info icon This preview shows pages 2–4. Sign up to view the full content.

View Full Document Right Arrow Icon
008/resources/img/turtle/starry_ec.gif) """ import turtle wn = turtle.Screen() t=turtle.Turtle() wn.setup(800,600) wn.bgcolor("black") t.pencolor("yellow") #turning animation off wn.tracer(0)
Image of page 2

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
#Part One def draw_star(x,y,size): t.up() t.goto(x,y) #draw the lines for i in range(5): t.down() #angle star side t.right(144) #use the inputted size t.forward(size) #return t.up() turtle.update() #Part Two #draw several stars #for i in range(25): #draw_star(0,300-i*50, 100) #draw star 3 import random def generate_star_data(quantity): totallist=[] for i in range(quantity): #each time there is an iteration, must be empty stars=[] #random x and y x_value= random.randint(-400,400) y_value= random.randint(-300,300) size= random.randint(0,75) #append to list one stars.append(x_value) stars.append(y_value) stars.append(size) #append this global list totallist.append(stars) return (totallist) star_data = generate_star_data(40) print(star_data) # prints out: [[-250, 121, 49], [100, 0, 20]] #Part 4 def draw_sky(): #iterate again over global for i in (star_data): #every value index (x, y, size) draw_star(i[0],i[1],i[2]) draw_sky()
Image of page 3
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern