Scientific Computing Using Python - PHYS:4905 - Fall 2018
Python Homework #2
Due 8/28/2018
Name _______________________________________________
1. (1) Write lines of Python code to find the number of bits needed
to write the number 255.
2. (4) Using Python, make an array with values from 0 to 350 with a
step of 10. Make a second array with the cosine of those
values taken to be angles in degrees. Find the average of the
cosines and the standard deviation of the cosines. Write your
code and those numbers below.
3. (2) Modify the code in the previous question to remove the cosine
values with absolute magnitude greater than 0.5. Find
the average and the standard deviation of the remaining
cosines. Write your code and those numbers below.
4. (1) Write Python code to produce a 4×4 matrix that has the values
1, 2, 3, 4 along the diagonal and is zero everywhere else.