Created
March 16, 2023 03:50
-
-
Save cemkaplan75/6c00ca767d994237b341a4e76ef946fa to your computer and use it in GitHub Desktop.
First Assignment
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#For the past week, you've been watching your coworker Harold use a calculator to manually track stock price fluctuations. Harold spends three hours every day tracking his stocks this way, logging the stock's original price (from the day before), the current price, and the percentage of increase or decrease. You know that automating this calculation would streamline Harold's daily process, leaving more time for making investment decisions. Your new Python skills can help you achieve this for him. | |
#In this activity, create a Python program to automate Harold's process by programmatically implementing the percent increase calculation. | |
#Start small by identifying the percent increase in price for Apple stock. Yesterday at 9:00 a.m., Apple's stock price was $198.87. At close of market today, the stock price was $254.32. Calculate the percent increase using the following formulas: | |
#Increase = Current Price - Original Price | |
#Percent Increase = Increase / Original x 100 | |
original_price=198.87 | |
print(original_price) | |
current_price=254.32 | |
print(current_price) | |
increase = (current_price)-(original_price) | |
rounded = round(increase, 2) | |
print(rounded) | |
percent_increase = increase / original_price | |
percentage = "{:.2%}".format(percent_increase) | |
print(percentage) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I've printed rounded increase as with the name rounded. I hope I used correct formula for round. It worked anyways :)