# Stock Transaction Program Python

The “Chapter 2 – #12: Stock Transactivity Program – Tony Gaddis – Starting Out With Python” programming difficulty originates from Tony Gaddis’ book, “Starting Out through Python (4th Edition, Global Edition)”

## Problem

Last month, Joe purchased some stock in Acme Software, Inc. Here are the details of the purchase:

* The variety of shares that Joe purchased was 2,000. * When Joe purchased the stock, he paid \$40.00 per share. * Joe paid his stockbroker a commission that ainstalled to 3 percent of the amount he phelp for the stock.

You watching: Stock transaction program python

Two weeks later, Joe offered the stock. Here are the details of the sale:

* The number of shares that Joe sold was 2,000. * He offered the stock for \$42.75 per share. * He phelp his stockbroker another commission that ainstalled to 3 percent of the amount he obtained for the stock.

Write a regimen that display screens the adhering to information:

* The amount of money Joe passist for the stock. * The amount of commission Joe paid his broker as soon as he bought the stock. * The amount for which Joe sold the stock. * The amount of commission Joe passist his broker as soon as he offered the stock. * Display the amount of money that Joe had left once he marketed the stock and also paid his broker (both times). If this amount is positive, then Joe made a profit. If the amount is negative, then Joe shed money.

## Solution

STOCKBROKER_COMMISSION = .03shares_sold = shares_purchased = 2000price_per_share = 40.00amount_paid_for_stock = shares_purchased * price_per_shareprint(' Amount of money phelp for the stock = \$', format(amount_paid_for_stock, ',.2f'), sep='')commission_paid_when_bought = amount_paid_for_stock * STOCKBROKER_COMMISSIONprint('Amount of commission passist to broker when Joe bought the stock = \$', format(commission_paid_when_bought, ',.2f'), sep='')price_per_share = 42.75amount_stock_sold_for = shares_sold * price_per_shareprint('Amount for which Joe sold the stock = \$', format(amount_stock_sold_for, ',.2f'), sep='')commission_paid_when_sold = amount_stock_sold_for * STOCKBROKER_COMMISSIONprint('Amount of commission phelp to broker as soon as Joe sold the stock = \$', format(commission_paid_when_offered, ',.2f'), sep='')total_amount_left = amount_stock_sold_for - (commission_paid_when_bought + commission_paid_when_sold)print(' Total leftover =', format(total_amount_left, ',.2f'), ' Joe made a profit. ')

## Video Walk Through

This video includes a action by step procedure of exactly how to settle “Chapter 2 – #12: Stock Transaction Program – Tony Gaddis – Starting Out With Python”.

## That’s it for Chapter 2 – #12: Stock Transactivity Program

Thank you for taking an interemainder in what I do! I hope it was helpful for you as a lot as it aided me alengthy my journey in learning to code!

## Python Chapter 2 Solutions Here:

Starting Out With Python | Chapter 2 | Programming Challenge Solutions

## Chapter 2 References:

end= and also sep= Escape Characters Python Strings the print() feature Variable Types float() feature int() function format() function