The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | May 2017 |
| Last Sign in: | 398 Weeks Ago, 2 Days Ago |
| Questions Answered: | 66690 |
| Tutorials Posted: | 66688 |
MCS,PHD
Argosy University/ Phoniex University/
Nov-2005 - Oct-2011
Professor
Phoniex University
Oct-2001 - Nov-2016
Python Programming Question Python 3
PROGRAM A: APROGRAM.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 and then use a loop to add ten integers to the list, each in the range from 10-90. These integers will represent angles measured in degrees. main should then call playlist and savelist, in that order. Both of these functions take the 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 number and sum of the even numbers and the number and sum of the odd numbers.
The savelist function:
save list should sort the list and write each element to a text file named AB.txt, each element on its own line.
PROGRAM B: BPROGRAM.py
This program should read the angles from AB.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.
SAMPLE OUTPUT:
Here are the angles in degrees:
23 85 31 55 42 85 72 33 39 20
3 even angles total to 134
7 odd angles total to 351
List of angles was written to file.
End of program A.
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
End of program B.
Hel-----------lo -----------Sir-----------/Ma-----------dam-----------Tha-----------nk -----------You----------- fo-----------r u-----------sin-----------g o-----------ur -----------web-----------sit-----------e a-----------nd -----------and----------- ac-----------qui-----------sit-----------ion----------- of----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n.P-----------lea-----------se -----------pin-----------g m-----------e o-----------n c-----------hat----------- I -----------am -----------onl-----------ine----------- or----------- in-----------box----------- me----------- a -----------mes-----------sag-----------e I----------- wi-----------ll