Objective: By the end of this lesson, learners will be able to perform basic Python operations, work with data types, lists, dictionaries, and loops, and understand JSON structures for data handling.
Topics Covered:
Basic arithmetic: +, -, *, /, ** (exponents), % (modulo).
Order of operations (PEMDAS/Parentheses priority).
Key Concepts:
Boolean (bool): True/False (e.g., 10 > 9).
String (str): Text in quotes ("Hello").
Numeric:
int (whole numbers), float (decimals), complex (imaginary).
Sequences:
Lists: Ordered, mutable, duplicates allowed ([1, "a", 3.5]).
Tuples: Ordered, immutable ((1, "a")).
Sets: Unordered, no duplicates ({1, 2}).
Dictionaries (dict): Key-value pairs ({"key": "value"}).
Binary: Non-human-readable data (e.g., bytes).
Activity:
Identify data types in given examples (e.g., type(123)).
Skills Practiced:
Creating lists: price_usd = [100, 200, 300].
Accessing items: Indexing (price_usd[0]) and negative indexing (price_usd[-1]).
Modifying lists: append() to add items.
Aggregations: sum(), len(), and calculating averages.
Zipping lists: Combine two lists into pairs (zip(list1, list2)).
Activity:
Create a list of areas, append a value, and calculate the total/average.
Key Concepts:
Iterate over lists:
Indentation is critical for loop blocks.
Activity:
Print each item in a list of property types.
Skills Practiced:
Creating dictionaries: {"key": "value"}.
Accessing values: dict["key"] or dict.get("key").
Retrieving keys: dict.keys().
Activity:
Create a dictionary for a property and print its keys/values.
Key Concepts:
JSON = JavaScript Object Notation (key-value pairs).
Used for data storage/transport (similar to Python dictionaries.
Activity:
Compare Python dictionaries vs. JSON structures.
Review:
Math operations, data types, lists, loops, dictionaries, JSON.
Further Reading:
Links to Python docs (provided in original content).
Final Challenge:
Combine concepts:
Create a list of property dictionaries.
Use a loop to print each property’s details.
Calculate the average price.
Access the whole lesson here: Python: Getting Started.