Week 03 Python Assignment
Due by Tuesday, September 14th, 2021
Part A: Twitter Decoding (must (1) demo during class (2) upload to Gradescope by 11:45pm)
Part B: Enhanced Calculator (due to Gradescope by 11:45pm)
Welcome to your assignment for Week 03 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 3 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: Twitter Decoding (3 points)
Introduction
To get started, open IDLE and then create a New File via the File menu. We
suggest you immediately save this file in the directory you created to manage all
102 Python Labs this semester. Save this file as
Week3A-twitter.py.
Section 17.13 in your zyBook (an optional Section that we encourage you to do, though not required)
provides a program that decodes a few common abbreviations
in online communication. For example, in Twitter or Messages, one might use LOL
instead of typing "laughing out loud". Your goal in this
assignment is to augment the code provided in our zyBook in order to expand the number of
abbreviations that can be decoded. Specifically, add these popular abbreviations:
BTW, DM, AFAIK, and IDK.
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: TWEET>
.
- 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
Enter the Tweet or Message abbreviation to decode.
TWEET> IDK
The decoded abbreviation is:
OUTPUT IDK = I don't know
Gradescope Submission Nuances
You will demo this lab in class on Tuesday and should also submit it to Gradescope after demoing in class.
Because this is a demo lab, no tests will be run upon submission to Gradescope—your grade will be based on your performance in the demo. However,
proper I/O formatting is still required.
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 A
# Week 3 - Lab A - Twitter Decoding
# References: TA Abi for if syntax
# Time: 20 minutes
Part B Assignment: Enhanced Calculator (3 points)
To get started, open IDLE and then 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:
Week3B-enhanced_calculator.py.
Consider our Simple Calculator from Week 2 - Part A, which asks the user for two real numbers, calculates four operations,
and outputs the result. In this lab, your program should only complete a single operation (i.e., an operation chosen by the user).
- Declare operand_one and operand_two variables, initializing each to 0.0.
- Declare the variables sum, difference, product, quotient and remainder, and initialize each to 0.0.
- Prompt the user to input a real number as the first operand, assigning it to your operand_one variable.
- Prompt the user to input a real number as the second operand, assigning it to your operand_two variable.
- Ask the user which operation they would like to have performed.
- Calculate the result of the operation.
- Output the result based on the user's choice. Include SIX decimal places for
addition, subtraction, and multiplication and ZERO decimal places for division.
Hint: As before, for division, use operand_one as the dividend and operand_two as the divisor.
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 #1
Welcome to our Enhanced Calculator!
Input the first operand.
FIRST> 3.14
Input the second operand.
SECOND> 2.72
Choose one of the following operations:
1 - addition
2 - subtraction
3 - multiplication
4 - division
OPERATION> 2
The result of the subtraction is: 0.420000
OUTPUT 0.420000
Thank you for using our calculator.
Example Execution #2
Welcome to our Enhanced Calculator!
Input the first operand.
FIRST> 12
Input the second operand.
SECOND> 7
Choose one of the following operations:
1 - addition
2 - subtraction
3 - multiplication
4 - division
OPERATION> 4
The result of the division is: 1 (quotient) and 5 (remainder)
OUTPUT 1
OUTPUT 5
Thank you for using our calculator.
Gradescope Submission Nuances
Part B 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 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 G
# Week 3 - Lab B - Enhanced Calcuator
# References: Instructor Dylan to get started
# Time: 25 minutes
Submit Solutions
Follow these steps
to submit your files to Gradescope.
- In Gradescope, go to Assignments > Week3A and
upload Week3A-twitter.py.
- In Gradescope, go to Assignments > Week3B and
upload Week3B-enhanced_calculator.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.
|