Python Class Notes
1. Introduction to Python
Python is a popular programming language known for its readability and versatility. It supports
multiple programming paradigms including procedural, object-oriented, and functional
programming.
2. History of Python
Python was created by Guido van Rossum and first released in 1991. It was designed with the
philosophy of code readability and ease of use in mind.
3. Installation and Setup
To install Python, visit python.org and download the latest version. Use 'python --version' in the
terminal to verify installation.
4. Basic Syntax
• Indentation: Python uses indentation (usually 4 spaces) to define code blocks.
• Comments: Use # for single-line comments and triple quotes for multi-line comments.
• Case Sensitive: Variables and identifiers are case sensitive.
5. Python Data Types
• Numeric: int, float, complex
• Sequence: list, tuple, range
• Text: str
• Mapping: dict
• Set Types: set, frozenset
• Boolean: bool
• None Type: None
6. Control Structures
Python provides control structures like if-else, for loops, and while loops to control program flow.
7. Functions
Functions in Python are defined using the 'def' keyword. Example:
def add(a, b):
return a + b
8. Object-Oriented Programming
Python supports OOP concepts like classes, objects, inheritance, and polymorphism.
9. Popular Libraries
• NumPy: Numerical computations
• Pandas: Data analysis
• Matplotlib: Data visualization
• Requests: HTTP requests
• Django/Flask: Web development
10. Practice Questions
• Write a Python program to print 'Hello, World!'
• Create a function that takes two numbers and returns their sum.
• Write a program to check if a number is even or odd.
• Create a list of 5 fruits and print them one by one using a loop.
• Write a program to calculate factorial of a number using recursion.