In order to receive credit for lab, you must attend your lab section and submit your work during that lab. You cannot attend another lab section, and you cannot submit from elsewhere (e.g. your dorm room). We want you to go to lab since you will get additional information from your course assistant that will help you, and you will be able to work with other students to share ideas and learn how to solve problems more effectively. It is also important to go to lab and use the Linux machines since your lab exams will be run on these machines so you need to familiarize yourself with this environment.
If you go to a different lab section or submit the work early or late, you will receive a 0. You are allowed to drop 2 labs without penalty, so please do not ask for makeups. Look ahead at your schedule to see if you will be missing a lab due to another event and plan on dropping that lab. If you drop a lab, you are still responsible for reviewing the material covered. (Note: You must be in attendance for lab exams. Lab exams cannot be dropped.)
Place these files in a lab2 folder. Before leaving lab, zip up this folder, and hand it in.
Type each of the following expressions into python3. What value do each of the following Python expressions evaluate to? Is that value an integer or a floating point?
Write your answers in the file answers.txt. (Review Unit 2A lecture slides if necessary.)
In circle_area.py, define a Python function circle_area(r) that calculates and returns the area of a circle given radius r. This can be calculated using the formula:
A = π r^{2}Also in the file circle_area.py, define a Python function print_circle_area(r) that calculates and prints the area of a circle given radius r.
In answers.txt, explain in your own words the difference between print and return.
In sphere_vol.py, define a Python function sphere_vol(r) that calculates and returns the volume of a sphere with a radius r. This can be calculated using the formula:
V = (4/3) π r^{3}Place in answers.txt a copy of your interaction with python3 in which you call sphere_vol(r) to compute the volume of a sphere with a radius of 7, and python3 shows you the result.
Pick a mathematical formula that is used in your major. In a file called my_func.py, create a python3 function that calculates some value using that formula.
At the beginning of your my_func.py include a comment (one or more lines of English text that start with "#" and are ignored by python3) that describes what the fomula the function computes and what units the parameters and results are in.
Create a zip file called lab2.zip that contains your text files, and submit it for grading using the handin instructions. Be sure that you create a zip file and not a compressed file in another format.