Question: write this in Pythom Code. In this assignment, we will apply lists, tuples, set and / or dictionaries to solve a problem with first -

write this in Pythom Code.
In this assignment, we will apply lists, tuples, set and / or dictionaries to solve a problem with first-class functions.
Imagine this scenario: A company / individual buys 100 shares of a stock at $12 per share, then another 100 of the
same stock at $10 per share, and then sells 150 shares at $15. After the sale, taxes must be paid (capital gains tax.
But what is the profit since two different prices were paid for the stock. Well, the IRS has a rule for this situation. It
is an asset-management and valuation method in which the assets (in this case stocks bought first are sold first.
So, we must sell all shares of the first batch for a sale amount of $300($3 x 100, then 50 of the shares from the
second batch, for a sale amount of $250($5*50, yielding a total sale amount of $550. This assumes all the stocks
are from the same company. We made 550 but we must pay tax at a rate of 15%. So, the tax is $82.50 and the take-
home is $467.50.
We will write code to solve this problem. The best solution is one based on classes, but for now we will use our
collections. Later we can revisit this with classes and objects.
For our solution, we will do these calculations for arbitrary purchases and sales of shares of multiple companies.
Specifications
Present the user with a menu of three options:
o Buy (B or b)
o Sale (S or s)
o Print (P or p)
o Exit (E or e)
Do not assume the user will enter valid data.
o This means invalid entry for the menu, prices, stock quantity.
o Note When selling, you cannot sell more stock than you have! Keep that in mind.
If the user selects Buy, then prompt the user for the three-letter symbol, the quantity, and the price.
If the user selects Sale, then prompt the user for the three-letter symbol, if the symbol exists in those bought,
then prompt for the quantity sold and price. Make sure you do not sell more than the number of stocks
available.
o Display the number of units sold at each purchase price and the total amount for the sale, the tax, and
the total take-home. Use the example above as a test case. Your output should be formatted to two
decimal places.
If the user selects Print, then display the name of the stock along with all number of shares and the purchase
price. Remember, you may have multiple copies of the same share.
If the user selects Exit, then close the application.
You may use any number / combinations of the data structures we have discussed in class.
Use user-defined methods for user input, validation, calculations, etc...
Do not forget the DocString Comment in your functions.
o Note Your menu should be in its own module and called from main
 write this in Pythom Code. In this assignment, we will apply

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!