🧠 SemiSimTech Intuition Lab

Python Fundamentals Intuition Lab

A structured memory-map for Python fundamentals: variables, operators, flow control, data structures, functions, file operations, exceptions, modules, and object-oriented thinking.

Seed Structure
state → logic → structure → abstraction
Core Theme
Python as computational structure
Main Skills
types, loops, containers, functions
Learning Goal
Build a stable syntax memory map

📚 Navigation

🧩 Big Picture

Python fundamentals can be organized as a small number of recurring structures. Instead of memorizing isolated syntax, build a map: state representation → logic control → information organization → abstraction → robustness → persistence → system modeling.

VariablesFlow ControlData StructuresFunctionsOOP
Fundamental intuition

A Python program stores information, makes decisions, repeats actions, organizes data, packages reusable logic, handles failures, reads/writes files, and eventually models systems with objects.

Master frame

🧭 Master Memory Map

1. State

Variables and types represent information.

2. Logic

Operators, conditions, and loops control execution.

3. Structure

Lists, dictionaries, tuples, sets, and strings organize data.

4. Abstraction

Functions and modules package repeated logic.

5. Robustness

Exceptions prevent one error from collapsing the whole program.

6. Modeling

Classes and objects model entities with attributes and behavior.

Layer 1 — State

📦 Variables & Data Types

Variables attach names to values. Data types define what operations are meaningful for those values.

Basic variable and type examples
x = 10                 # int
ratio = 3.14           # float
name = "Python"        # str
items = [1, 2, 3]      # list
point = (1, 2)         # tuple
info = {"id": 7}       # dict
unique = {1, 2, 3}     # set
TypeExampleIntuition
int / float10, 3.14Numbers for counting and continuous values.
str"abc"Text sequence.
list[1,2,3]Ordered, mutable collection.
tuple(1,2)Ordered, usually fixed collection.
dict{"key": "value"}Key-value lookup table.
set{1,2,3}Unique unordered collection.
Layer 2 — Logic

🧮 Operators

Operators are the small logic blocks that transform or compare values.

CategoryOperatorsMeaning
Arithmetic+ - * / // % **Add, subtract, multiply, divide, integer divide, remainder, power.
Comparison== != > < >= <=Produce True / False decisions.
Logicand or notCombine Boolean conditions.
Membershipin, not inCheck whether a value is inside a container.
Operator example
price = 2800
distance = 3.2

is_good = price < 3000 and distance < 5
print(is_good)
Layer 3 — Control

🔀 Flow Control

Flow control decides which code runs and how many times it runs.

Conditions

if / elif / else
if condition:
    do_this()
elif another_condition:
    do_that()
else:
    do_default()

Loops

for / while
for item in items:
    print(item)

while condition:
    keep_running()
Memory anchor

break exits the loop. continue skips the current iteration and moves to the next one.

Layer 4 — Information organization

🧱 Data Structures

List

Ordered, mutable collection. Good for sequences.

List operations
nums = [1, 2, 3]
nums.append(4)
nums.insert(0, 0)
nums.remove(2)
nums.sort()

Dictionary

Key-value structure. Good for lookup and labeled data.

Dictionary operations
person = {"name": "Ada", "age": 30}
print(person["name"])
print(person.get("city", "unknown"))
person["age"] = 31
del person["age"]
StructureBest useCommon methods
listOrdered changing sequenceappend, insert, pop, sort
dictNamed lookup tableget, keys, values, items
strText processingsplit, join, strip, replace
setUnique valuesadd, remove, union/intersection
tupleFixed grouped valuesindexing, unpacking
Layer 5 — Abstraction

🧩 Functions

A function packages repeated logic into a reusable block.

Function structure
def function_name(param1, param2="default"):
    """Explain what the function does."""
    result = param1 + param2
    return result
ConceptPatternMeaning
Callname(args)Use a function.
Positional argumentf(1,2)Arguments matched by order.
Keyword argumentf(x=1)Arguments matched by name.
Default argumentdef f(x=0)Use default if not provided.
*argsdef f(*args)Accept many positional arguments.
**kwargsdef f(**kwargs)Accept many keyword arguments.
lambdalambda x: x+1Small unnamed one-line function.
Layer 6 — Persistence

📄 File Operations

Files allow information to survive after the program stops.

Open modes

ModeMeaning
rRead
wWrite and overwrite
aAppend
bBinary mode

Recommended pattern

Automatic close with context manager
with open("data.txt", "r") as f:
    text = f.read()

with open("out.txt", "w") as f:
    f.write("hello")
Layer 7 — Robustness

🛡️ Exception Handling

Exception handling prevents one local failure from crashing the entire system.

try / except / else / finally
try:
    result = risky_operation()
except ValueError:
    handle_bad_value()
else:
    run_if_no_error()
finally:
    always_cleanup()
Engineering intuition

Use exceptions to isolate risk: file missing, bad input, network failure, conversion error, or unexpected data format.

Layer 8 — Reuse

📦 Modules & Imports

Modules organize functions, classes, and constants into reusable files or packages.

PatternMeaningComment
import moduleImport whole moduleClear namespace.
import module as mImport with aliasCommon for long names.
from module import functionImport one itemConvenient but less explicit.
from module import *Import everythingUsually not recommended.
Common examples
import math
import pandas as pd
from pathlib import Path
Layer 9 — System modeling

🏗️ Object-Oriented Programming

OOP models an entity as data plus behavior.

Core concepts

TermMeaning
ClassBlueprint.
ObjectConcrete instance of a class.
AttributeObject feature / stored state.
MethodObject behavior.
InheritanceChild class receives parent behavior.
PolymorphismDifferent classes implement same method differently.

Class skeleton

Simple class
class Device:
    def __init__(self, name, voltage):
        self.name = name
        self.voltage = voltage

    def describe(self):
        return f"{self.name}: {self.voltage} V"

d = Device("LDMOS", 12)
print(d.describe())
Quick toolbox

🧰 Common Built-in Functions

FunctionUseMemory anchor
print()OutputShow information.
input()InputReceive user text.
len()LengthCount elements.
type()Type checkInspect what something is.
int(), str(), float()ConversionChange representation.
range()Number sequenceLoop counter source.
enumerate()Index + valueTrack position while looping.
zip()Pair itemsWalk two lists together.
max(), min(), sum()AggregationSummarize values.
sorted()New sorted listSort without modifying original.
map()Apply functionTransform each element.
filter()Keep matching valuesSelect by condition.
open()File accessRead or write files.
Practice

🏋️ Small Practice Exercises

1. State

Create variables for name, price, distance, and tags. Print their types.

2. Logic

Use if to classify a candidate as good if price and distance pass thresholds.

3. Structure

Store several candidates as dictionaries inside a list, then loop through them.

4. Function

Write a function that calculates a score from price and distance.

5. File

Write results into a text file using with open(...).

6. Robustness

Add try/except around number conversion from user input.

🧠 Flashcards

Click each card to reveal the answer.

Q1. What is a variable?
A name attached to a value, representing program state.
Click to reveal / hide
Q2. What is the difference between list and dict?
A list is ordered by index; a dict is accessed by key.
Click to reveal / hide
Q3. What does a function do?
It packages reusable logic with inputs and optional return values.
Click to reveal / hide
Q4. Why use with open(...)?
It automatically closes the file after the block exits.
Click to reveal / hide
Q5. What does try/except protect?
It protects the program from expected failure points such as bad input or missing files.
Click to reveal / hide
Q6. What is a class?
A blueprint for objects that combine attributes and methods.
Click to reveal / hide

📘 Glossary

variable

A name referring to a value.

type

The category of a value, such as int, str, list, or dict.

condition

A True/False expression used to choose a path.

loop

A repeated execution structure.

list

An ordered mutable collection.

dict

A key-value mapping.

function

A reusable block of logic.

module

A reusable Python file or package.

exception

A runtime error event that can be handled.

class

A blueprint for objects.

object

A concrete instance of a class.

method

A function attached to an object.

🚀 Final Insight

Python fundamentals are not random syntax pieces; they are a compact system for representing information, controlling logic, and building reusable structure.

Once this map is stable, advanced tools such as Pandas, Matplotlib, automation, and machine learning become easier to learn because they all reuse the same foundations.