Chapter 1
How Python Code Executes
• Python code runs line by line (interpreter-based)
• No need to compile manually — interpreter handles it
• Each line is converted into bytecode, then executed by the
Python Virtual Machine (PVM)
• Errors stop execution immediately
• Example:
print('Hello')
print('World')
Variables & Memory Concept
• Variable = name that stores a value in memory
• In Python, variables are used to store data that can be
referenced and manipulated during program execution
• Example:
x = 10
y = 'Hello'
• Python automatically decides the data type
• Variables are references (labels) pointing to memory
objects
• Use id() to check memory location:
print(id(x))
Taking User Input
• Use input() to get user input
• Example:
name = input('Enter your name: ')
print('Hello', name)
input() always returns string
• Convert it before performing calculations
Expressions
Combination of operators and operands
x=10 [ not expression ]
x+3 [ expression, 2 operands, 1 operator and returns a value ]
Python Fundamentals – Quick Cheat Sheet
• Concept | Example | Output
Print | print('Hi') | Hi
Variable | x = 5 | stores 5
Input | input('Enter:') | takes user input
Type Conversion | int('10') | 10
Round | round(3.1415, 2) | 3.14
More Topics
• Expressions and statement - Book
• Comment
• Indentation
Summary
• ✅ Python executes code line-by-line
• ✅ Variables store references in memory
• ✅ Input always returns string
• ✅ Expressions and statement - Book
• ✅ Comment
• ✅ Indentation