Uploaded by jessiega

Homework 1

advertisement
CS 1315 – Spring 2021
Homework 01
Check Canvas/Gradescope for the time and date that this assignment is due
Files to Submit:
• hw01.py
The file(s) you submit should be named exactly as specified. Letter casing matters! Please note that JES may
sometimes generate additional files. Make sure you submit .py files, and not .pylog or .bak files. We will only
grade the files you submit to Gradescope.
Safe Submission:
1. Go back to Gradescope and double check what you have turned in. Download a copy of it and verify
that it is exactly what you intended to submit. Turning in the correct file and validating that you have
done that correctly is solely your responsibility. Seriously. It Is solely your responsibility. Correct
submission is something that you are required to do. It is your job to verify it.
2. You can submit your homework file multiple times on Gradescope until the cut-off time. We will grade
your last submission.
Collaboration Policy:
• Do your own work. You can discuss your homework with other people, but you are not allowed to
share files or copy each other's code.
• Rule: Never give or take code from another student. Period. Working together is not equivalent to
copying another person's work and passing it off as your own, as that is cheating.
• Do not take another person's work, nor give your work to another student (equally considered
cheating). How do you prevent others from copying your work? Never, ever, under any circumstances
give someone else a copy of your homework solution/code. And by never, we mean never. Not when
they want to "see how you did it" nor when "I lost mine" nor when "I just need an idea of how to do
it". Students are sent to the Office of Student Integrity over cheating on homework. If you give your
homework to someone, that is a free opportunity to turn it in as their own. If they do, you are as guilty
as they are of cheating. Period.
• This homework must be completed using structures, functions, and materials that have been
presented in lecture or recitation/workshop.
Other Important Details:
1. If your .py file fails to load, you will receive a 0 for all coding problems
2. If your function contains an error, you will receive a 0 for that problem
3. If you fail to name your function as described in a problem, points will be deducted for that problem;
please take the time to properly name your functions as described by the "Function Name" section for
each problem, capitalization and spelling included
4. The test case(s) provided serve solely as examples to check your answers against; do not assume these
are the only values we will test when we grade your code; your output should always match what is
given for the test cases however
Coding Problems:
0. Required Name Comment
1. Hello World!
2. Tell Us About Yourself!
3. Math Problem
4. Successful Mindset
5. Payday!
PROBLEM 0: Required Name Comment
A set of required information that you must enter as comments. A comment is a piece of text that is preceded
by the # symbol and is used to provide information to any human who might read the code. The JES
interpreter ignores comments completely.
Required Information:
1. A comment that includes your name
2. A comment that includes your GT e-mail address
3. A comment that includes one of the two acceptable collaboration statements:
a. "I worked on the homework assignment alone, using only this semester's course materials."
b. "I worked on this homework with [give the names of the people you worked with] and referred
to [cite any texts, web sites, or other materials not provided as this semester's course materials
for CS 1315]."
For example, if your name is George Burdell, insert the following line of text (including the # symbol) at the top
of your python file:
# George Burdell
# gBurdell81@gatech.edu
# I worked on this homework assignment alone, using only this semester's
# course materials.
PROBLEM 1: Hello World!
Function Name: helloWorld
Parameters: None
Return value: None
Description:
Welcome to CS 1315! For this problem, write a function that prints each of the following sentences on
separate lines: "Hello there!", "Programming is exciting", "I will rock it in CS 1315 this semester!". When you
run this function in the command window (the black part at the bottom of JES) it should look exactly like the
test case below. Happy coding!
Test Cases:
>>> helloWorld()
Hello there!
Programming is exciting
I will rock it in CS 1315 this semester!
PROBLEM 2: Tell Us About Yourself!
Function Name: allAboutMe
Parameters: None
Return Value: None
Description:
We want to know more about you! Write a function that prints out statements with your name, your
major, and something you are excited for. The print statements should be formatted as shown below but
include information about you instead.
Note: the autograder will give full credit when your first line starts with "My name is", the second line starts
with "I am studying", and the third line starts with "I am looking forward to". However, when we grade your
code manually, we will give credit for anything reasonable.
Test Cases:
>>> allAboutMe()
My name is Maxim.
I am studying Computer Science at Georgia Tech
I am looking forward to graduating at the end of this semester!
PROBLEM 3: Math Problem
Function Name: mathProblem
Parameters: None
Return Value: None
Description:
After learning about the types of math JES can do, you have decided to give up on buying expensive
calculators (your bank account will appreciate this). Write a function that prints the first two statements as
shown below, and then prints the remainder of 734 divided by 12. Your function must do the math! Don't just
print 2 to get the last line.
Test Cases:
>>> mathProblem()
We can do math in Python!
The remainder of 734 divided by 12 equals
2
PROBLEM 4: Successful Mindset
Function Name: success
Parameters: None
Return Value: None
Description:
Georgia Tech University consistently brings in the brightest minds from around the globe, and while
you have the capability to succeed at this institute, the pressure, workload, and stress can at times be
daunting and overwhelming. To promote a positive mindset going into the semester, we want you to write a
function that prints the sentence "I will be successful now and going forward!" 30 times. Make sure the
punctuation and spacing is correct. There is a very quick way to do this with multiplication! Much easier than
writing it all by hand.
Test Cases:
>>> success()
I will be successful now and going forward!
going forward! I will be successful now and
successful now and going forward! I will be
forward! I will be successful now and going
now and going forward! I will be successful
be successful now and going forward! I will
forward! I will be successful now and going
now and going forward! I will be successful
be successful now and going forward! I will
forward! I will be successful now and going
now and going forward! I will be successful
be successful now and going forward! I will
forward! I will be successful now and going
now and going forward! I will be successful
be successful now and going forward! I will
forward! I will be successful now and going
now and going forward! I will be successful
be successful now and going forward! I will
forward!
I will be successful now and
going forward! I will be
successful now and going
forward! I will be successful
now and going forward! I will
be successful now and going
forward! I will be successful
now and going forward! I will
be successful now and going
forward! I will be successful
now and going forward! I will
be successful now and going
forward! I will be successful
now and going forward! I will
be successful now and going
forward! I will be successful
now and going forward! I will
be successful now and going
PROBLEM 5: Payday!
Function Name: payday
Parameters:
• wage – a number denoting the hourly wage
Return Value: None
Description:
As Cardi B once said, "Nothing in this world that I like more than checks!" Write a function that takes in
an integer parameter, the hourly pay. Given that you work 40 hours a week, we want to figure out how much
your gross annual income would be (there are 52 weeks in a year). Your function should calculate the correct
pay and print the sentence shown in the test cases below. Formatting is important! Remember to check your
data types.
Test Cases:
>>> payday(15)
I will make $31200 this year.
>>> payday(24.15)
I will make $50232.0 this year.
Download