Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Homework #1
- # 10/08/2019
- # Pg 105 Problem 12 (161)
- # Pg 106 Problem 14 (162)
- # Jose Zepeda
- # Problem 12
- # Last month, Joe purchased some stock in Acme Software, Inc. Here are the
- # details of the purchase:
- # -The number of shares that Joe purchased was 2,000.
- # -When Joe purchased the stock, he paid $40,000 per share.
- # -Joe paid his stockbroker a commision that amounted to 3 percent of the amount
- # he paid for the stock.
- # Two week later, Joe sold the stock. Here are the details of the sale:
- # -The number of shares that Joe sold was 2000.
- # -He sold the stock for $42.75 per share.
- # -He paid his stockbroker another commission that amounted to 3 percent of the
- # amount he received for the stock
- # Write a program that displays the following information:
- # -The amount of money Joe paid for the stock.
- # -The amount of commssion Joe paid his broker when he bought the stock.
- # -The amount for which Joe sold the stock.
- # -The amount of commission Joe paid his brokere when he sold the stock.
- # -Display the amount of money that Joe had left when he sold the stock and paid
- # his broker (both times). If this amount is positive, then Joe made a profit.
- # If this amount is negative that Joe lost money.
- number_shares_purchased = 2000
- amount_paid_per_share = 40.00
- total_stock_purchased = number_shares_purchased * amount_paid_per_share
- commission_to_broker = total_stock_purchased * .03
- number_shares_sold = 2000
- amount_sold_per_share = 42.75
- total_stock_sold= number_shares_sold * amount_sold_per_share
- commission_paid_to_broker = total_stock_sold * .03
- print('Total Amount paid for Stock: $'+ format(total_stock_purchased, ",.2f"))
- print('Commission for Buying: $' + format(commission_to_broker, ",.2f"))
- print('Amount sold the Stock: $' + format(total_stock_sold, ",.2f"))
- print('Commission for Selling: $' + format(commission_paid_to_broker, ",.2f"))
- profit = (total_stock_sold - commission_paid_to_broker) - \
- (total_stock_purchased - commission_to_broker)
- print('Total Profits: $' + format(profit, ",.2f"))
- # Problem 14
- # When a bank account pays compound interest, it pays interest not only on the
- # prinicipal amount that was deposited in 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 of years is:
- # A=P(1+rn)nt
- # The terms in the formula are:
- # - A is the amount of money in the account after the specified number of years.
- # - P is the principal amount that was originally deposited into the account.
- # - r is the annual interest rate.
- # - n is the number of times per year that the interest is compounded.
- # - t is the specified number of years.
- # Write a program that makes the calculation for you. The program should ask the
- # user to input the following:
- # - The amount of principal originally deposited into the account.
- # - The annual interest rate paid by the account.
- # - The number of times per year that the interest is compounded (For example,
- # if interest is compounded monthly, enter 12. If interest is compounded
- # quarterly, enter 4.)
- # - The number of years the account will be left to earn interest.
- # Once the input data has been entered, the program should calculate and display
- # the amount of money that will be in the account after the specified number of
- # years.
- print('Calculate compound interest by inputting values.')
- print('Your initial deposit to your account.')
- principal = float(input('Princal Deposit:'))
- print('Input annual percentage rate example-')
- print('10 for 10% without the symbol and not dividing to 0.1.')
- rate = float(input('Enter Annual Interest Rate Percentage:'))
- print('Compound interest example-')
- print('12 for monthly, 4 for quarterly, or 1 for annually.')
- compound = float(input('Annual Compound Frequency:'))
- print('Number of years you would like to compound your \
- interest?')
- time = float(input('Years:'))
- print('')
- accrual = principal*(1+((rate/100/compound))**compound*time)
- print('Amount compounded after',time,'years is: $'+format(accrual,'.2f'))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement