MODULE 1: Programming Environment & Basics
Python Interpreter and Environments
The Python interpreter is a program that reads Python code and executes it line by line. It first
converts the code into bytecode and then executes it using the Python Virtual Machine (PVM). This
makes Python an interpreted language, allowing easy debugging and portability.
Different environments include IDLE (basic built-in editor), Jupyter Notebook (interactive
environment for data analysis), and PyCharm (professional IDE with advanced features like
debugging and project management).
Data Types in Python
Python provides several built-in data types such as integers (int), floating-point numbers (float),
strings (str), lists, tuples, sets, and dictionaries. Lists are mutable, tuples are immutable, sets store
unique elements, and dictionaries store key-value pairs.
Control Statements
Control statements include decision-making statements like if, if-else, and elif, and looping
statements like for and while loops. These help in controlling the flow of execution of a program
based on conditions.
Example Programs
Prime Number: A number is prime if it has only two divisors. A loop checks divisibility up to n/2.
Fibonacci Series: Generates numbers where each term is the sum of the previous two.
Sum and Average: Uses a loop to calculate total and divides by count to get average.
MODULE 2: Building Python Programs
Data Structures
Lists, tuples, sets, and dictionaries are important data structures. Lists allow modification, tuples are
fixed, sets remove duplicates, and dictionaries map keys to values efficiently.
Functions and Recursion
Functions are reusable blocks of code defined using def keyword. Recursion is when a function
calls itself to solve smaller parts of a problem, such as factorial calculation.
Strings and File Handling
Strings support operations like slicing, concatenation, and formatting. File handling is done using
open(), read(), write(), and close() functions.
Programs
Character Frequency: Count occurrences using a dictionary.
Sorting Without Built-ins: Use loops like bubble sort.
File Word Count: Read file and count words using split().
MODULE 3: Graphics
Event Driven Programming
Event-driven programming responds to user actions like mouse clicks and key presses. It is widely
used in GUI applications.
Turtle Graphics
Turtle graphics allows drawing shapes using commands like forward(), backward(), right(), and
left(). It is useful for beginners.
CLI vs GUI
CLI (Command Line Interface) uses text commands, while GUI (Graphical User Interface) uses
windows, buttons, and icons for interaction.
Programs
Hexagon Drawing: Use turtle with loop of 6 iterations.
Tkinter GUI: Used to create forms and input fields.
Image Display: Use GUI libraries to load and display images.
MODULE 4: Object-Oriented Programming
Classes and Objects
A class is a blueprint for creating objects. Objects are instances of a class containing data and
methods.
Inheritance
Inheritance allows a class to inherit properties from another class. Types include single, multiple,
multilevel, hierarchical, and hybrid inheritance.
Exception Handling
Exception handling is done using try, except, else, and finally blocks to handle runtime errors
gracefully.
Programs
Rectangle Class: Calculates area and perimeter.
Operator Overloading: Redefines operators using special methods like __add__.
Multiple Exceptions: Handles different errors separately.
MODULE 5: Data Processing
NumPy
NumPy is a library used for numerical operations. It provides fast array processing and
mathematical functions.
Pandas
Pandas provides DataFrame and Series for handling structured data. It is widely used in data
analysis.
Matplotlib
Matplotlib is used for data visualization such as line charts, bar graphs, and histograms.
Programs
CSV Handling: Use pandas.read_csv() to read data.
Bar Graph: Use matplotlib to plot graphs.
Matrix Multiplication: Use NumPy dot() function.