Question

In: Computer Science

Starting out with Python 4th edition Chapter 2 Programming Exercise 12 Stock Transaction Program Not sure...

Starting out with Python 4th edition

Chapter 2 Programming Exercise 12 Stock Transaction Program

Not sure how to do this

Solutions

Expert Solution

CODE

purchased = 2000

buyValue = 40.0

commission = 3 / 100

sellValue = 42.75

sold = 2000

amountPaid = purchased * buyValue

purchCommission = amountPaid * commission

amountReceived = sold * sellValue

sellCommission = amountReceived * commission

amountLeft = amountReceived - sellCommission - purchCommission - amountPaid

print("Joe paid", amountPaid, "dollars for his stocks")

print("His broker was paid", purchCommission, "dollars during the purchase")

print("Joe's stocks sold for", amountReceived, "dollars")

print("The broker was paid", sellCommission, "dollars during the sale")

if amountLeft < 0:

print("Joe lost", abs(amountLeft), "dollars")

else:

print("Joe made", amountLeft, "dollars")


Related Solutions

Chapter 6, Starting out with Programming and Logic, 4th Edition, Page 265 #6 Kinetic Energy In...
Chapter 6, Starting out with Programming and Logic, 4th Edition, Page 265 #6 Kinetic Energy In physics, an object that is in motion is said to have kinetic energy. The following formula can be used to determine a moving object’s kinetic energy: KE=12mv2 The variables in the formula are as follows: KE is the kinetic energy, m is the object’s mass in kilograms, and v is the object’s velocity, in meters per second. Design a function named kineticEnergy that accepts...
Textbook: Starting out with Python (3rd or 4the Edition) Question: Programming Exercise # 9 - Trivia...
Textbook: Starting out with Python (3rd or 4the Edition) Question: Programming Exercise # 9 - Trivia Question In this programming exercise, you will create a simple trivia game for two players. The program will work like this: Starting with player 1, each player gets a turn at answering 5 trivia questions. (There should be a total of 10 questions.) When a question is displayed, 4 possible answers are also displayed. Only one of the answers is correct, and if the...
Python Programming 4th edition: Write a program that asks the user for the number of hours...
Python Programming 4th edition: Write a program that asks the user for the number of hours (float) and the pay rate (float) for employee pay role sheet. The program should display the gross pay with overtime if any and without overtime. Hints: Given base_hr as 40 and ovt_multiplier as1.5, calculate the gross pay with and Without overtime. The output should look like as follows: Enter the number of hours worked: Enter the hourly pay rate: The gross pay is $XXX.XX
Starting Out with Python 4th ed., Page 104 Programming exercise #14 When a bank account pays...
Starting Out with Python 4th ed., Page 104 Programming exercise #14 When a bank account pays compound interest, it pays interest not only on the principal amount that was deposited into the account, but also on the interest that has accumulated over time. Suppose you want to deposit some money into a savings account, and let the account earn compound interest for a certain number of years. The formula for calculating the balance of the account after a specified number...
Python Programming 4th Edition: Write Boolean expression: 1)A currently have a different value than B 2)...
Python Programming 4th Edition: Write Boolean expression: 1)A currently have a different value than B 2) B less than the sum of the current values of A and C 3)C is no more than 15. 4) 75 is between the values of integers A and B 5) Number N is divisible by 2 or it is divisible by 3. 6) X is positive and Y is positive
In An Introduciton to Programmig Using Visual Basic tenth edition chapter 6 the 4th project program...
In An Introduciton to Programmig Using Visual Basic tenth edition chapter 6 the 4th project program has me using loops. I am having a hard time trying to figure out what the double declining balance methods depreciation value is. It is 2 divided by the items life, but multiplied by the previous years balance. I do not know how to find the previous years balance to use in the depreciation value. Thank you
guide to unix using linux / 4th edition / chapter 2 / p10 2.10 Assume that...
guide to unix using linux / 4th edition / chapter 2 / p10 2.10 Assume that you work for a company that is developing a telephone database and you are creating directories for the Mail and Receiving Departments, which are referenced in the company’s budget and accounting systems as departments 4540 and 4550. After you create the directories, you begin creating files of department phone numbers to store in those directories. You must use the mkdir (make directory) command to...
This is an exercise to design and write a Python program in good programming style for...
This is an exercise to design and write a Python program in good programming style for a simulation of stock price over a period of 100 days. In this exercise, you are asked to simulate the stock price starting at $100.00 for 100 days with a daily fluctuation based on the Normal Distribution with mean = 0.0 & sigma = 0.0125. The program will show the daily stock price, the 7-day minimum, the 7-day maximum, the 7-day average, and the...
Starting Out with Java (6th Edition) chapter 8, 3PC Requirement: Each of the RoomCarpet and RoomDimension...
Starting Out with Java (6th Edition) chapter 8, 3PC Requirement: Each of the RoomCarpet and RoomDimension classes should have a toString method, an equals method, a copy method, and a copy constructor. The RoomCarpet class should have mutators and accessors for both of its fields.
Chapter 8 Programming exercise 6 "Days of each month" Original Exercise: Design a program that displays...
Chapter 8 Programming exercise 6 "Days of each month" Original Exercise: Design a program that displays the number of days in each month. The program’s output should be similar to this: January has 31 days. February has 28 days. March has 31 days. April has 30 days. May has 31 days. June has 30 days. July has 31 days. August has 31 days. September has 30 days. October has 31 days. November has 30 days. December has 31 days. The...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT