Skip to content

Create hello.py #180

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Work/bounce.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# bounce.py
#
# Exercise 1.5
height = 100
i=1
while i < 10:
height = height * 0.6
i = i+1
print(i, height)

1 change: 1 addition & 0 deletions Work/hello.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
print("Hello World")
29 changes: 29 additions & 0 deletions Work/mortgage.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,32 @@
# mortgage.py
#
# Exercise 1.7


principal = 500000.0
rate = 0.05
payment = 2684.11
total_paid = 0.0
month = 0.0

#User-defined extra payment variables
extra_payment_start_month=61 # Extra payments start after 5 years (month 61)
extra_payment_end_month = 108 # Extra payments end after 4 years (month 108)
extra_payment = 1000 # Extra payment amount
while principal > 0:
# Chack if the current month is within the extra payment period
if extra_payment_start_month <= month < extra_payment_end_month:
monthly_payment = extra_payment + payment
else:
monthly_payment = payment
# Apply monthly interest and substract the payment
principal = principal * (1+rate/12) - payment
total_paid += monthly_payment
month +=1
# Final adjustment if the principal goes negative
if principal < 0:
total_paid = total_paid + principal # Adjust the last payment
principal = 0 # Set principal to 0 to exit the loop
print(f'Month: {month} vs {total_paid}')


18 changes: 18 additions & 0 deletions Work/pcost.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
# pcost.py
#
# Exercise 1.27
import csv
each_share = 0.0
shares = 0.0
prices = 0.0
total_cost = 0
with open('/Users/doston_ra/practical-python/Work/Data/portfolio.csv', 'rt') as file:
reader = csv.reader(file)
next(reader)
for line in reader:

shares= float(line[1])
prices = float(line[2])
each_share = shares * prices
total_cost += each_share

print('Total cost is ', total_cost)


15 changes: 15 additions & 0 deletions Work/sears.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

bill_thickness = 0.11 * 0.001 # Meters
sears_height = 442 # height meters
day = 1
num_bills = 1

while bill_thickness * num_bills < sears_height:
print(day, num_bills, num_bills * bill_thickness)
day = day + 1
num_bills = num_bills * 2

print('Number of days', day)
print('Number of bills', num_bills)
print('Final height', num_bills * bill_thickness)