Week 11 Python Assignment
Due by Tuesday, November 16th, 2021
Part A: Function Practice (submit to Gradescope by 11:45pm)
(No Part B)
Welcome to your assignment for Week 11 of CSCI 102! Each week, after Studio, you
should work on that week's homework assignment (lab). This lab is to be done on
your own (not pair programming), and needs to be completed and submitted to
Gradescope no later than 11:45 PM on the due date. Unlike CSCI 101, we will place all
assignments for a given week on one HTML page. This is your Week 11 CSCI 102 Assignment page.
Good news: only ONE 102 lab assignment this week.
Function Practice! (6 points)
To get started, open IDLE and create a New File via the File menu. We
suggest you immediately save this file in the directory managing all
your 102 Python Labs this semester. Please save this file with the following name:
Week11-function_practice.py.
The purpose of this lab is to create the following five functions (with the function names
listed) in the linked file above.
- print_output - The input to this function
is a string. The output of the function is the word "OUTPUT" followed by the
input string. Here's an example of using this function:
>>> print_output("Hello World")
OUTPUT Hello World
- triangle_hypotenuse - The input to this function is two numerical values
which represent two side lengths of a right triangle. The function should (1) compute
the length of the hypotenuse of the right triangle (two decimal places) and (2) call your
print_output function to print the result (two decimal places).
Here are two examples of using this function:
>>> triangle_hypotenuse(3,4)
OUTPUT 5.00
>>> triangle_hypotenuse(4.2,7.8)
OUTPUT 8.86
- feet_to_meters - The input to this function is a number that represents the number of feet.
The function should then (1) convert the number of feet to meters and (2)
call your print_output function to print the result (four decimal places).
Note: 1 ft is equal to 0.3048 meters.
Here's an example of using this function:
>>> feet_to_meters(10)
OUTPUT 3.0480
- polar_coords - The input to this function is two vales (x,y) representing
cartesian coordinates. The function should then (1) convert the coordinates to the
equivalent location in polar coordinates (search Google for this conversion, if needed)
and (2) call your print_output function (twice) to print the result (two
decimal places).
Note: Be sure to output your degrees in deg (not radians). Here's an example
of using this function:
>>> polar_coords(12,5)
OUTPUT r: 13.00
OUTPUT theta: 22.62
- dollars_to_euros - The input to this function is the amount
something costs in Dollars. The function should then (1) convert the amount to
euros (rounded down to two decimal places) and (2) call your print_output
function to print the result. Assume one Dollar is worth 0.86 Euros. Here's an
example of using this function:
>>> dollars_to_euros(10)
OUTPUT 8.60
Notes:
- The code you submit to Gradescope should only contain your created functions.
- Our test script will call
your functions with the function names listed above. You will not receive credit for a function
call if your function name does not match the name above.
Gradescope Submission Nuances
Part A will ONLY be submitted to Gradescope (you will NOT demo this lab in class).
When you submit your Python file to Gradescope, multiple different test
cases are run on your code. Passing all of the tests results in a 100% on
the autograded portion of the lab.
You are allowed to submit to Gradescope
four
times (or less) for this lab. The maximum grade of your submissions will be your grade for
the lab. Note: If your code doesn’t work (e.g., a syntax error exists,
or an error is thrown in execution), then you will receive an
AUTOMATIC ZERO. You
should test your code before submitting to ensure it executes correctly.
Comments
All Python files should include a header with your name,
section, assignment info, references (i.e., who did you collaborate
with on this assignment?; what resource did you use?), and approximate
time taken to do the assignment. Be sure to cite any
allowed external references used to complete the assignment.
Any code without this header will lose 1 point. Here's an
example:
# Tracy Camp
# CSCI 102 – Section E
# Week 11 Lab
# References: None
# Time: 25 minutes
Submit Solutions
Follow these steps
to submit your files to Gradescope.
- In Gradescope, go to CSCI 102 > Week11 and upload
only Week11-functions.py.
To receive full credit, your code must execute in
Python 3, you must submit a single file for the assignment (your Python code file),
and you should submit one file with only your functions in it.
Whenever you submit something to Gradescope, we
strongly recommend you always double check what
you submitted actually got submitted correctly
(e.g., did the file upload correctly? did you
submit the correct file? etc.) If your submission
is incorrect, it's on you.