Week 01 Python Assignment
Due by Tuesday, August 31st, 2021
Part A: Hypotenuse (must (1) demo during class and (2) upload to Gradescope by 11:45pm)
Part B: A Rectangular Conundrum (due to Gradescope by 11:45pm)
Welcome to your assignment
for Week 01 of CSCI 102! Each week, you will typically have multiple homework assignments (labs).
These labs are to be done on your own (not pair programming), with one lab to be demoed in class Tuesday.
All labs (including the demo labs) need to be submitted to Gradescope by 11:45pm on the due date.
Unlike CSCI 101, we will place all assignments for a
given week on one HTML page. This is your Week 1 CSCI 102
Assignment page.
You have TWO problems to do this week, the first of which (Part A) you will
demo in class with a TA on Tuesday. Details on Part A and Part B are below.
Part A: 3 points
Assignment: Hypotenuse
Introduction
To get started, open IDLE and create a New File via the File
menu. We suggest you immediately save this file in the CSCI102
directory managing all your Python Labs this semester. Please
save this file with the following name: Week1A-hypotenuse.py.
The purpose of this lab is to
write a program that calculates and prints the square of the
hypotenuse of a right triangle. Your program should implement
the following algorithm.
- Ask the user to enter a positive integer (A).
- Ask the user to enter a second positive integer (B).
- Assign C to be the square of the hypotenuse
of the right triangle with leg lengths A and B.
- Print C with the correct output formatting.
Lab I/O Format
For lab assignments this semester, a specific Lab
Input/Output Format is required. This format
is described below:
- When prompting for input, use the prompt string
WORD> , where WORD
is a single, uppercase word which describes the input. For
example, this lab might choose: A>
and B> .
- When providing output that will be graded, start the line
with the word
OUTPUT followed by exactly one space, e.g. OUTPUT .
Think of this as "boxing your answer" on a math worksheet; it lets us quickly
find your answer. Gradescope will skip any output
lines that do not start with OUTPUT .
- You are welcome to have other output lines that do not
begin with OUTPUT; Gradescope
will ignore these.
- A submission without exactly correct output formatting will receive an AUTOMATIC ZERO.
This is because Gradescope is automated—it does not look at your code, only the results, and thus
the format of the results must be consistent for all students.
Example Execution
Input the first positive integer.
A> 4
Input the second positive integer.
B> 5
The square of the hypotenuse is:
OUTPUT 41
Gradescope Submission Nuances
You will demo this lab in class on Tuesday, August 31 and also submit it to Gradescope.
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 received 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 C
# Week 1 -
Part A
#
References: Instructor Christine helped me with the input statement
#
Time: 30 minutes
Part B: 5 points
Assignment: A Rectangular Conundrum
To get started, open IDLE and create a New File via the File
menu. We suggest you immediately save this file in the
CSCI102 directory managing all your Python Labs this
semester. Please save this file with the following name: Week1B-rectangle.py.
While working at your Uncle’s farm, he asked you to build a fence to contain his cow,
Sheila, who is constantly escaping to the cow oasis nearby. However, due to the remote
location, he only has a certain length of fence that you can use. Given the total length of
fencing, what is the maximum rectangular area within which you can contain Sheila?
Your program should implement the
following algorithm.
- Ask the user for the total length of fencing available (in yards).
Store the value entered as a variable, and make sure
to convert to an integer. You may assume that the user
will only enter a positive, whole-valued length of fencing.
- Convert the length from yards to feet (there are 3 feet in a yard).
- Calculate the maximum area that the fence can bound.
- Print the maximum area to the console. Use the round()
function to output the area with one decimal. Make sure to have the proper output formatting.
Lab I/O Format
The same I/O Format on Part A is required on Part B. Please see the Lab I/O formatting
specifications in Part A if you need a refresher.
Example Execution
Input the total length of fencing available (in yards).
LENGTH> 45
The maximum rectangular area that can be bound (in feet) is:
OUTPUT 1139.1
Gradescope Submission Nuances
Part B will ONLY be submitted to Gradescope (you will NOT demo this lab in class)—please see Part A
for the nuances of submitting to Gradescope.
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:
#
John Henke
# CSCI
102 – Section C
# Week
1 - Part B
#
References: my friend Sally Johnson showed me how to print
#
Time: 30 minutes
Request Assistance
We encourage you to connect with an
instructor or TA through an
office hour.
Submit Solutions
Follow these steps
to submit your files to Gradescope.
- In Gradescope, go to Assignments > Week1A and
upload Week1A-hypotenuse.py.
- In Gradescope, go to Assignments > Week1B and
upload Week1B-rectangle.py.
To receive credit, your code must execute in
Python 3, and you must submit a single file for each
portion of the assignment (your Python code file).
In addition, your code must follow the Lab I/O
Format.
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.
|