Lesson 02

Data types and control flow

These primitives are the building blocks for every script and system you’ll write.

Numbers and strings

# Numbers
tax_rate = 0.12          # float
units = 7                # int
total = units * 9.5
with_tax = total * (1 + tax_rate)
print(with_tax)

# Strings
title = "SigLabs"
tagline = f"Welcome to {title}"
print(tagline.upper())
print("abc".replace("b", "x"))

Collections

# Lists (ordered, mutable)
prices = [10.0, 12.5, 9.9]
prices.append(11.2)

# Tuples (ordered, immutable)
point = (3, 4)

# Dicts (key-value)
instrument = {"symbol": "SIG", "price": 12.34}
instrument["currency"] = "USD"

# Sets (unique, unordered)
seen = {"AAPL", "MSFT"}
seen.add("GOOG")

Conditionals

price = 12.5
if price > 20:
    label = "expensive"
elif price > 10:
    label = "fair"
else:
    label = "cheap"
print(label)

Loops

# for-loop
symbols = ["SIG", "EURUSD", "BTC"]
for s in symbols:
    print(s)

# while-loop
count = 3
while count:
    print(count)
    count -= 1

Comprehensions

# List, dict, set comprehensions
nums = [1, 2, 3, 4, 5]
squares = [n*n for n in nums]
evens = {n for n in nums if n % 2 == 0}
index = {n: i for i, n in enumerate(nums)}
print(squares, evens, index)

Accelerate with SigLabs Financial Software

Forecasting, market screening, risk insights, and reporting—built for speed and clarity.

Next steps

You’re ready for functions, modules, and venv in Lesson 03.