Unit 2: Introduction to Python – Deep Learning
Notes
1. Basics of Python Programming
Python is a high-level, interpreted programming language known for its simplicity and readability.
Key Features:
• Easy to learn and write
• Open-source and free
• Portable (runs on all platforms)
• Dynamically typed (no need for variable type declaration)
• Large standard library
2. Python Interpreter
Mode Description Example
Interactive Executes code line-by-line in REPL Type python in terminal
Script Executes code saved in a .py file python [Link]
3. Structure of a Python Program
A typical program includes comments, imports, functions/classes, and the main code block.
Example:
print('Hello, World!')
4. Indentation
Python uses indentation to define blocks of code instead of braces.
5. Identifiers, Keywords, Constants, and Variables
Concept Meaning Example
Identifier Name for variable or function name, totalMarks
Keyword Reserved word with special meaning if, for, while
Constant Fixed value PI = 3.14
Variable Stores data value age = 17
6. Operators and Precedence
Operators perform operations on variables and values.
Type Examples Purpose
Arithmetic +, -, *, /, %, ** Math operations
Comparison ==, !=, >, < Compare values
Logical and, or, not Combine conditions
Assignment =, +=, -= Assign values
Membership in, not in Check presence
Identity is, is not Compare memory location
7. Data Types
Type Example Mutable?
int 10 No
float 10.5 No
str 'Hello' No
bool True / False No
list [1,2,3] Yes
tuple (1,2,3) No
dict {'a':1} Yes
set {1,2,3} Yes
Deep Reflection:
“Programming isn’t about typing; it’s about thinking.” Python rewards clarity and logic — the simpler
your code, the smarter your thought.