Skip to content
๐ŸHello, Finance World!

Hello, Finance World!

beginner Python 3 minprintstringsarithmetic
What you'll learn
  • print
  • strings
  • arithmetic

Hello, Finance World! ๐Ÿ‘‹

This is it - your very first program. Every quant at Goldman Sachs, every economist at the ECB, every data scientist at BlackRock once sat exactly where you are sitting now, about to make a computer say something for the very first time. Today the machine speaks because you tell it to. Welcome aboard ๐ŸŽ‰

The print() function

print() displays text on the screen. It's your main tool for showing results.

Python
print("Hello, World!")   # prints:  Hello, World!
print(42)                # prints:  42
print(3.14)              # prints:  3.14

The quotes matter: "Hello, World!" is text (Python calls it a string), and Python displays it exactly as written, character for character. Numbers need no quotes.

๐Ÿง  The mental model: the receipt printer

Picture your program as the cash register in a busy cafรฉ. Inside, it can add, multiply and juggle numbers all day - but all of that happens silently, invisibly, in the machine's memory. print() is the receipt printer: it is the only way the register shows the outside world what it computed. No print(), no receipt - the maths happened, but nobody saw it.

That is why print() is the first thing every programmer learns: it makes the invisible visible.

Basic arithmetic

Python can do maths just like a calculator:

SymbolOperationExampleResult
+Addition10 + 515
-Subtraction10 - 55
*Multiplication10 * 550
/Division10 / 42.5

Printing words and numbers together

Give print() several things separated by commas and it shows them on one line, with spaces in between:

Python
total = 1745.5
print("Total cost:", total)   # prints:  Total cost: 1745.5

Your Task

  1. Write your first line of code: print the message "Welcome to EcoFinLearn!". The starter has a print("...") waiting for you - replace the three dots with the message (keep the quotes!).
  2. Step 2 is already written for you: an AAPL share costs $174.55, you buy 10 shares, and the program prints the total cost.

Predict before you run: what number will the second line show? Multiplying by 10 just slides the decimal point one place to the right - do it in your head with 174.55, then press Run and check. When both lines match, you have officially written your first program. ๐Ÿฅณ