Skip to main content

💯 2a - Using python to calculate things

Introductory Exercise:

Calculating Profits: Fix the following program

Calulating Profits

Profits are calulated as Profit = Revenue - Cost

The programmer who created the following code made a huge mistake and calculated profits as Revenue + Cost please fix this program!

🔨 Fix the program here:

Calculating Profits: Solving a new formula

Calculating Profit Margin

What is Profit Margin? - ClayTrader business

Profit margins are calculated as Profit Margin = (Net Profit / Revenue) * 100 Finish the following program so that the program prints your

🔨 Fix the program here:

Optional Assigments

The secret of building wealth: Compound Interest

👀 Instructor Notes

This might be a concept harder to understand but here we have a program that approximates how rich you will be if you started an investing account (and you don't add or remove money from your investing account)

note

Image extracted from Navicore

age_start_investing = 20
age_retirement = 22
initial_investment = 1000
yearly_interest_percent = 5

expected_yearly_interestgain = 1.00 + yearly_interest_percent*0.01

worth_end = initial_investment* expected_yearly_interestgain**(age_retirement - age_start_investing)
print("\nInvestment Calculator \n -----------------")
print("If you create an investment account at:\n age {age_start_investing} with an yearly interest rate of {yearly_interest_percent} percent ".format(age_start_investing=age_start_investing, yearly_interest_percent=yearly_interest_percent))
print('\nAt the age of {age_retirement} your ${initial_investment} will become: {worth_end}'.format(age_retirement=age_retirement, initial_investment = initial_investment, worth_end= worth_end))

🧪 Try the code out!

Calculating your future wealth of a single investment

🧪 Play with the following code!

Play around with the next python code

  • Try changing the age you start investing (e.g. from 18 to 20)
  • Try changing your initial investment (e.g. from 1000 to 2000)
  • Try Changing the interest_rate (e.g. from 8 % yearly to 12%)

But what if I invest $1000 every year? 🙋‍♂️

Me Stressing

Image extracted from ahseeit.com

Calculating your future wealth of multiple investments

🧪 Play with the following code!

Play around with the next python code

  • Try changing the age you start investing (e.g. from 18 to 20)
  • Try changing your initial investment (e.g. from 1000 to 2000)
  • Try Changing the interest_rate (e.g. from 8 % yearly to 12%)

** Don't worry about the code below line 8**


Cheating your Physics Exam

The following program calculates the position of something based on variables: These are the linear motion formulas

Disclaimer

I don't condone cheating or anything related to actual academic dishonesty, this is just a what if scenario... ٩(。•́‿•̀。)۶

Image extracted from real-world-physics

Fix the following speed printer

The following program doesn't follow the formula properly please fix it (it should print 32 when v1 = 2, aceleration = 3 and time = 10)

initial_velocity =  2
aceleration = 3
time_elapsed = 10

print("Velocity of the object at time: "+ str(time_elapsed))
print(initial_velocity + aceleration)

🔨 Fix the program here: