Scientific Computing Using Python - PHYS:4905 - Fall 2018
Python Homework #1
Due 8/23/2018


Name _______________________________________________

1. (1) Write lines of Python code to assign the value 8 to the variable b, the value 2 to the variable a, and then check if b equals a raised to the 3rd power.  What value does your code produce?




2. (1) What does Python return for the expression 4/3?  How about 4.0/3.0?  Which version of Python are you using?





3. (1) Write a line of Python code to import the sqrt function from the numpy library so that you can call the function by writing "sqrt(a)".  Write a second line of code to import all the functions from the numpy library so that you can call the square root function by writing "np.sqrt(a)".







4. (2) Write lines of Python code to assign to the variable c the cosine of the variable theta where theta is expressed in degrees.  Note that the functions and constants that you need are in the numpy library and you have several choices of how to access them.