Skip to content
Advertisement

Novice Python User having issues with simple functions

I am trying to make a simple python program that takes 3 inputs

  1. Number of stocks I will Buy
  2. Price per share of stock when bought
  3. Price per share of stock when sold.

In this exercise, there is a 15% commission fee both when buying, and selling the stock.

The 4 outputs I am attempting to receive are:

  1. Price of bought stock (price per share when bought * number of shares)
  2. Commission on the bought stock
  3. Price of sold stock (price per share when sold * number of shares)
  4. Commission on the sold stock.

I am attempting to do this in a way that utilizes functions to stay organized. I realize that functions are not strictly necessary for this program, but the point of this exercise is to help me understand how to use functions a little better.

When I run my program, I receive this Error:

JavaScript

Here is my program:

JavaScript

The indention when copying / pasting to stack overflow ended up a little wonky. I’m not sure how to fix that.

I apologize if there are any egregious formatting errors, I am new to Python and Stack Overflow.

Advertisement

Answer

JavaScript

Good luck with python! :)

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement