Marion Coders- Python Exercise - Feb 2, 2018

The rows below contain links to three Python programs and give related instructions. The fourth row gives instructions for a program that you are asked to write.
Exercise #

 

Description of Python program

 

Link to Python Program Student Exercise  
1 This Python program displays the values that would be used to draw a sequence of short lines on the screen. It tells how long the line segment will be and the angle to to turn before drawing the next short line. line_values_1.py

Enter this program using the Idle editor and run it. Though you could copy it and paste it into the editor, you will learn more if you type it in using your keyboard. Study the program with the goal of understanding what each line in the program does. Notice the use of a function that returns a random value between 0 and 360.:

def rand_angle():
      myAngle = random.randrange(0,360);
     return(myAngle);


 
2 This program uses turtle graphics to draw a line, change it's pen size, change it's color, and change the direction in which it will draw pen_draw.py Enter and run this program in Idle. Try changing some of the values to get different line lengths, colors, pen size and direction.  
3 This program takes the program in exercise 1 and modifies it so that it draws the lines using the values displayed in that program. line_draw_1.py Enter and run this program. Study how each value that had been displayed by the program in execise 1 is used in tutrle graphic instruction (such as "myPen.lt(new_angle") to modify the line that is drawn  
4 This program displays values that could be used to draw a line. It is a modified version of the program in exercise #1. It is modified to display additional values ( color and pensize) that would be used to draw the sequence of lines line_values_2.py Enter and run this program. Study the separate functions used in the program ( random_pencolor, rand_angle, pen_width) and notice how they return a value when called.  
5 Your assignment is to write a program by modifying he program in exercise 4 to draw the line using the values chosen by that program    You will be modifying the program in exercise 4 in the same way that the program in exercise 1 was modified to create the program in exercise 3.  

The program in Exercise 4 displays the values that would be used in creating a line. Your task is to use turtle graphics [ e.g. "myPen.fd(new_dist) ] to draw that line on the screen