Register Now

Login

Lost Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Login

Register Now

Welcome to All Test Answers

lab 2 -Python

Write a program to calculate the amount of stock purchase, stocks sold and the profit or loss upon sale  using the following information?

1) The trading symbol is “CS2067”

2) Shares purchase on Dec 1 2018 :   5000 @ price 1.13

3) Shares  were sold on Jan 1 2019:   3567 @ price   1.59

4) The price of stock  on Jan 21 2019 is 1:80

5) Calculate the profit(loss) for the  item 3 (trade on Jan 1)

6) What would be the profit selling the remaining shares on Jan 21.

7) What is the total profit on the trade?

 

Your program should calculate and print out all the following

The Trading symbol for the company is:    CS2076

Price of shares purchased on Dec1 2018 :       answer         dollars

Value of shares  sold on Jan1 2019  :                answer        dollars

The amount of profit made on Jan1 :               answer       dollars

Value of shares sold on Jan21 :                          answer       dollars

Profit for Jan 21 trade is:                                      answer        dollars

Total Profit by trading the stock was:                 answer       dollars

Grading

2 points for comments in the code

6 point for meaningful variables names

2 point for each correct answer (12 points Total)

 

Answer

 

## Define all the variables
tradingSymbol = "CS2067"
numberOfSharesBuyDec1=5000
sharePriceBuyDec1 = 1.13
numberOfSharesSellJan1=3567
sharePriceSellJan1 = 1.59
sharePriceJan21 = 1.8

## Calculate the profit on Jan 1
profitJan1=(sharePriceSellJan1 - sharePriceBuyDec1)* numberOfSharesSellJan1

## Calculate the profit on Jan 21
profitLan21=(sharePriceJan21 - sharePriceBuyDec1) * (numberOfSharesBuyDec1 - numberOfSharesSellJan1)

## Calculate the total profit
totalProfit= profitJan1 + profitLan21

## Display the output rounded to 2 decimals points
print("The Trading symbol for the company is: ", tradingSymbol)

print("Price of shares purchased on Dec1 2018 : ", round(sharePriceBuyDec1*numberOfSharesBuyDec1,2) , 'dollars')

print("Value of shares sold on Jan1 2019 : ", round(numberOfSharesSellJan1 * sharePriceSellJan1,2) , 'dollars')

print("The amount of profit made on Jan1 : ", round(profitJan1,2) , 'dollars')

print("Value of shares sold on Jan21 : ", round((numberOfSharesBuyDec1 - numberOfSharesSellJan1) * sharePriceJan21,2) , 'dollars')

print("Profit for Jan 21 trade is: ", round(profitLan21,2) , 'dollars')

print("Total Profit by trading the stock was: ", round(totalProfit,2) , 'dollars')

About

Leave a reply

Captcha Click on image to update the captcha .

error: Content is protected !!