Back to Notes
Python5 min readMay 20, 2024

Python Fundamentals

Foundational Python programming syntax, standard libraries, matrix operations, list comprehensions, and data pipeline fundamentals.

Most of the logic behind programming is already familiar, even to someone who has never written a line of code. Following a recipe, sorting laundry by color, deciding whether to grab an umbrella based on the sky outside — all of these involve the same basic reasoning that a program runs through. Python just gives that reasoning a syntax a computer can execute.

Here's a look at the core building blocks of the language, using the kind of everyday situations they resemble.

1. Variables: labeled storage boxes

Picture moving into a new apartment. Kitchen utensils go into one box, labeled "Kitchen" and taped shut, so that reaching for a spatula later means going straight to the right box instead of searching through everything.

Variables work the same way. They hold a piece of information in memory under a name, so the program can refer back to it later.

# 'item_name' and 'price' are variables holding our data
item_name = "Coffee"
price = 4.50

2. Data types: what's inside the box

Milk doesn't go straight into a cardboard box — it needs a jug. Different kinds of contents call for different kinds of containers, and Python treats information the same way, keeping track of what type of data it's handling:

Data TypeEveryday EquivalentPython Example
String (str)Written words or text"Latte"
Integer (int)A whole count, like 3 cups3
Float (float)A price or measurement4.50
Boolean (bool)A light switch, on or offTrue or False

3. Input and output: ordering at a counter

At a cafe, the barista asks for a name, and the customer answers — that's input. Later, the barista calls the name out when the order is ready — that's output.

In Python, input() collects information from the user, and print() sends something back to the screen.

# Input: asking the user a question
customer_name = input("What's your name? ")
# Output: displaying a response
print("Order ready for " + customer_name + "!")

4. Operators: the math and comparison rules

Arithmetic and comparison show up constantly without being named as such — adding up the cost of three coffees, or checking a bank balance against a bill.

cup_price = 4.00
quantity = 2
total_cost = cup_price * quantity  # Multiplication operator (*)

wallet_balance = 10.00
can_afford = wallet_balance >= total_cost  # Comparison operator (>=) returns True

5. Control flow: navigating your day

Control flow is just the decision-making part of a program, working the same way a morning routine does: if it's raining, grab an umbrella; otherwise, put on sunglasses.

if, elif (else if), and else let Python follow a different path depending on which condition actually holds.

Putting it together: the smart barista script

This script combines variables, data types, operators, input/output, and control flow into one working program.

# --- 1. Input & Variables ---
print("--- Welcome to Python Cafe ---")
customer_name = input("What is your name? ")
wallet_balance = float(input("How much cash do you have in dollars? "))

# --- 2. Data Types & Operators ---
coffee_price = 4.50
tax_rate = 0.08  # 8% tax
total_price = coffee_price + (coffee_price * tax_rate)
print(f"\nOne coffee costs ${total_price:.2f} (including tax).")

# --- 3. Control Flow ---
if wallet_balance >= total_price:
    change = wallet_balance - total_price
    print(f"Enjoy your coffee, {customer_name}! Your change is ${change:.2f}.")
else:
    shortfall = total_price - wallet_balance
    print(f"Sorry {customer_name}, you're ${shortfall:.2f} short today!")

Key takeaway

Writing Python has less to do with memorizing symbols than with breaking a situation down into small, ordered steps. Once a variable reads as a labeled box and control flow reads as an everyday decision, the syntax stops being the hard part.

#Python#Programming#Data Pipelines#Fundamentals
Explore More Notes