- 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.
Pythonprint("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:
| Symbol | Operation | Example | Result |
|---|---|---|---|
+ | Addition | 10 + 5 | 15 |
- | Subtraction | 10 - 5 | 5 |
* | Multiplication | 10 * 5 | 50 |
/ | Division | 10 / 4 | 2.5 |
Printing words and numbers together
Give print() several things separated by commas and it shows them on one line, with spaces in between:
Pythontotal = 1745.5 print("Total cost:", total) # prints: Total cost: 1745.5
Your Task
- ›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!). - ›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. 🥳