• API
• FAQ
• Tools
• Archive
SHARE
TWEET # Untitled a guest Oct 15th, 2019 90 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. # Homework #1
2. # 10/08/2019
3. # Pg 105 Problem 12 (161)
4. # Pg 106 Problem 14 (162)
5. # Jose Zepeda
6.
7. # Problem 12
8. # Last month, Joe purchased some stock in Acme Software, Inc. Here are the
9. # details of the purchase:
10. # -The number of shares that Joe purchased was 2,000.
11. # -When Joe purchased the stock, he paid \$40,000 per share.
12. # -Joe paid his stockbroker a commision that amounted to 3 percent of the amount
13. #  he paid for the stock.
14. # Two week later, Joe sold the stock. Here are the details of the sale:
15. # -The number of shares that Joe sold was 2000.
16. # -He sold the stock for \$42.75 per share.
17. # -He paid his stockbroker another commission that amounted to 3 percent of the
18. #  amount he received for the stock
19. # Write a program that displays the following information:
20. # -The amount of money Joe paid for the stock.
21. # -The amount of commssion Joe paid his broker when he bought the stock.
22. # -The amount for which Joe sold the stock.
23. # -The amount of commission Joe paid his brokere when he sold the stock.
24. # -Display the amount of money that Joe had left when he sold the stock and paid
25. #  his broker (both times). If this amount is positive, then Joe made a profit.
26. #  If this amount is negative that Joe lost money.
27.
28. number_shares_purchased = 2000
29. amount_paid_per_share = 40.00
30. total_stock_purchased = number_shares_purchased * amount_paid_per_share
31. commission_to_broker = total_stock_purchased * .03
32.
33. number_shares_sold = 2000
34. amount_sold_per_share = 42.75
35. total_stock_sold= number_shares_sold * amount_sold_per_share
36. commission_paid_to_broker = total_stock_sold * .03
37.
38. print('Total Amount paid for Stock: \$'+ format(total_stock_purchased, ",.2f"))
39. print('Commission for Buying: \$' + format(commission_to_broker, ",.2f"))
40. print('Amount sold the Stock: \$' + format(total_stock_sold, ",.2f"))
41. print('Commission for Selling: \$' + format(commission_paid_to_broker, ",.2f"))
42.
43. profit = (total_stock_sold - commission_paid_to_broker) - \
44.          (total_stock_purchased - commission_to_broker)
45.
46. print('Total Profits: \$' + format(profit, ",.2f"))
47.
48.
49. # Problem 14
50. # When a bank account pays compound interest, it pays interest not only on the
51. # prinicipal amount that was deposited in the account, but also on the interest
52. # that has accumulated over time. Suppose you want to deposit some money into a
53. # savings account, and let the account earn compound interest for a certain
54. # number of years. The formula for calculating the balance of the account after
55. # a specified number of years is:
56. # A=P(1+rn)nt
57. # The terms in the formula are:
58. # - A is the amount of money in the account after the specified number of years.
59. # - P is the principal amount that was originally deposited into the account.
60. # - r is the annual interest rate.
61. # - n is the number of times per year that the interest is compounded.
62. # - t is the specified number of years.
63. # Write a program that makes the calculation for you. The program should ask the
64. # user to input the following:
65. # - The amount of principal originally deposited into the account.
66. # - The annual interest rate paid by the account.
67. # - The number of times per year that the interest is compounded (For example,
68. # if interest is compounded monthly, enter 12. If interest is compounded
69. # quarterly, enter 4.)
70. # - The number of years the account will be left to earn interest.
71. # Once the input data has been entered, the program should calculate and display
72. # the amount of money that will be in the account after the specified number of
73. # years.
74.
75. print('Calculate compound interest by inputting values.')
77. principal = float(input('Princal Deposit:'))
78. print('Input annual percentage rate example-')
79. print('10 for 10% without the symbol and not dividing to 0.1.')
80. rate = float(input('Enter Annual Interest Rate Percentage:'))
81. print('Compound interest example-')
82. print('12 for monthly, 4 for quarterly, or 1 for annually.')
83. compound = float(input('Annual Compound Frequency:'))
84. print('Number of years you would like to compound your \
85. interest?')
86. time = float(input('Years:'))
87. print('')
88. accrual = principal*(1+((rate/100/compound))**compound*time)
89. print('Amount compounded after',time,'years is: \$'+format(accrual,'.2f'))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

Top