program_p1.py

Be sure to follow the instructions religiously. It's not about getting the same or similar output by going your own way. It's about learning Python techniques, syntax, and concepts that you will need in future work.

Text References: Sections 2.3, 2.5, 2.6, 2.7, 2.8, 3.1, 3.2, 4.2, 4.3, 4.4, 4.5, 5.2, 5.3, 5.4, 5.6, 5.7, 5.8, 6.1, 6.2, 6.3, 7.2, 7.4, 7.5, 7.6.

1. program_p1.py

This program should use a main function and two other functions named playlist and savelist as follows:

The main function:

The main function should create an empty list named nums and then use a loop to add ten integers to nums, each integer in the range from 10-90. NOTE: In Python, a list is a data type. See Chapter 7. The main function should then call the playlist function and savelist function, in that order. Both of these functions take the nums list as a sole argument.

The playlist function:

playlist should use a loop to display the elements of the list, all on one line separated by a single space. playlist should also determine and print the total of the even numbers and the total of the odd numbers.

The savelist function:

save list should sort the list and write each element to a text file named angles.txt, each element on its own line.

SAMPLE OUTPUT

Here are the integers in nums:

23 85 31 55 42 85 72 33 39 20

Even integers total to 134

Odd integers total to 351

List of integers was written to file.

End of program.

2. program_p2.py

This program should consider that the integers in angles.txt represent angles measured in degrees. The program should read angles.txt and generate a table showing the trigonometric ratios sine, cosine, and tangent of the angles. The ratios should be displayed in formatted columns accurate to 5 decimal places as shown in the sample output below. See the math module functions on page 219. See also the format function on pages 68-71.

SAMPLE OUTPUT

Angle    Sine         Cosine      Tangent

20        0.34202    0.93969    0.36397

23        0.39073    0.92050    0.42447

31        0.51504    0.85717    0.60086

33        0.54464    0.83867    0.64941

39        0.62932    0.77715    0.80978

42        0.66913    0.74314    0.90040

55        0.81915    0.57358    1.42815

72        0.95106    0.30902    3.07768

85        0.99619    0.08716   11.43005

85        0.99619    0.08716   11.43005

Create a folder that identifies you and Assignment 1 such as smith_asst1 or asst1_jones. Save all Python programs to this folder. Omit the text file. Zip the folder. No .rar files allowed. Upload the zip to the Assignment 1 drop box.