'''lecture08_find_bug3.py Oliver W. Layton CS151: Computational Thinking: Visual Media Fall 2020 Find the 3 bugs below ''' import turtle import random def goto(x, y): '''This function is fine!''' turtle.up() turtle.goto(x, y) turtle.down() def drawLine(color, drawThickLine=False): '''Draws a thick or thin line at a random place on the canvas ''' # if drawThickLine == True: if drawThickLine: turtle.width(8) x = random.randint(-200, 200) y = random.randint(-200, 200) goto(x, y) turtle.forward(100) turtle.width(1) def main(numLines): '''Draws a thick line 50% of the time and thin line 50% of the time at a random location on the canvas ''' for i in range(numLines): # if random.random() < 0.5: # drawThickLine = True # else: # drawThickLine = False # drawLine('red', drawThickLine=drawThickLine) # if random.random() < 0.5: # drawLine('red', drawThickLine=True) # else: # drawLine('red', drawThickLine=False) drawThickLine = False if random.random() < 0.5: drawThickLine = True drawLine('red', drawThickLine=drawThickLine) # Main code if __name__ == '__main__': numLines = 50 main(numLines) turtle.exitonclick()