Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
Lecture Demos
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Daniel Moix
Lecture Demos
Commits
40c9c131
Commit
40c9c131
authored
8 months ago
by
Daniel Moix
Browse files
Options
Downloads
Patches
Plain Diff
Week 2 Lecture
parent
9e95bf1f
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
cs171/lect02/debug.py
+9
-0
9 additions, 0 deletions
cs171/lect02/debug.py
cs171/lect02/hello.py
+35
-1
35 additions, 1 deletion
cs171/lect02/hello.py
with
44 additions
and
1 deletion
cs171/lect02/debug.py
0 → 100644
+
9
−
0
View file @
40c9c131
def
addThese
(
a
,
b
):
return
a
+
b
# print(addThese(22, 7))
import
hello
import
math
print
(
hello
.
totalCollegeTuition
(
10000
,
2
))
\ No newline at end of file
This diff is collapsed.
Click to expand it.
cs171/lect02/hello.py
+
35
−
1
View file @
40c9c131
print
(
"
Hello CS 171
"
)
def
totalCollegeTuition
(
costPerTerm
,
numTerms
):
return
costPerTerm
*
numTerms
def
loanPayment
(
principal
,
rate
,
numMonths
):
rate
=
rate
/
12
onePlus
=
((
1
+
rate
)
**
numMonths
)
numerator
=
rate
*
onePlus
denominator
=
onePlus
-
1
payment
=
principal
*
(
numerator
/
denominator
)
return
payment
def
yearsToRepay
(
amountOwed
,
hourlyWage
):
hours
=
amountOwed
/
hourlyWage
weeks
=
hours
/
40
years
=
weeks
/
52
return
years
if
__name__
==
"
__main__
"
:
uniName
=
input
(
"
Name of university:
\n
"
)
costPerTerm
=
float
(
input
(
"
How much does one term cost?
\n
"
))
numTerms
=
int
(
input
(
"
How many terms are required to graduate?
\n
"
))
apr
=
float
(
input
(
"
What is the annual percentage rate? (ex: 0.055)
\n
"
))
numYears
=
int
(
input
(
"
How many year will you take to pay it back?
\n
"
))
months
=
numYears
*
12
totalTuition
=
totalCollegeTuition
(
costPerTerm
,
numTerms
)
payment
=
loanPayment
(
totalTuition
,
apr
,
months
)
print
(
"
Your total tuition will be
"
,
totalTuition
)
print
(
"
Your monthly payment will be
"
,
payment
)
totalLoanCost
=
payment
*
months
print
(
"
Your sum of payments is
"
,
totalLoanCost
)
years
=
yearsToRepay
(
totalLoanCost
,
7.25
)
print
(
"
You would need to work
"
,
years
,
"
years at minimum wage to repay your loan for attending
"
,
uniName
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment