Python Programming Lab — Free Notes & Tutorial
Free Python Programming Lab practicals for BCA/BTech — number patterns, star patterns, lists, tuples, dictionaries, sets, functions, OOP classes, file handling, NumPy arrays and Matplotlib charts, all runnable instantly in the built-in Python compiler. 100% free. Free Python Programming Lab course on SikshaSarovar.
This Python Programming Lab course is part of Siksha Sarovar and is 100% free for students in India — no sign-up required to read. It contains 55 structured lessons with examples, and pairs with our free online compiler and AI tutor.
What you will learn
- Python installation
- Arithmetic operators
- Datatypes
- Conditional statements
- Loops
- Number patterns
- Star patterns
- String slicing
- List methods
- List comprehension
- Tuples
- Dictionary methods
- Sets
- Linear search
- Binary search
- Function arguments
- Variable scope
- Classes and objects
- File handling
- NumPy arrays
- Matplotlib pie chart
- Matplotlib bar chart
Course content (55 lessons)
- Lab 0: Compiler Setup & Environment Check — Program Statement Verify that the built-in Python compiler (Pyodide, running in your browser) is ready to run the Python Programming Lab practicals. Compiler Info Property Value…
- 1. How to Install Python? Steps of Installation — Program Statement Explain the steps to install Python on a computer. Steps 1. Visit python.org/downloads and download the installer for your operating system. 2. Run the…
- 2. Print "Hello World!" — Program Statement Write a program to print "Hello World!". Concepts Covered - The print() built-in function - Python needs no main() function or semicolons — statements run top to…
- 3. Two Integers, Two Floats — All Arithmetic Operations — Program Statement Write a program to enter two integers, two floating numbers, and then perform all arithmetic operations on them. Concepts Covered - int and float literals -…
- 4. Declare Values to All Datatypes and Print Their Values with Types — Program Statement Write a program to declare values to all datatypes and print their values with types. Concepts Covered - Built-in types: int , float , complex , str , bool ,…
- 5. Check if a Number is Even or Odd — Program Statement Write a program to check if a number is even or odd. Concepts Covered - Modulus operator % - if / else conditional
- 6. Check if a Number is Positive, Negative or Zero — Program Statement Write a program to check if a number is positive, negative or zero. Concepts Covered - if / elif / else ladder
- 7. Print Square of Positive Numbers — Program Statement Write a program to print square of positive numbers. Concepts Covered - for loop over a range() - Only squaring numbers that pass a positivity check
- 8. Find the Largest Among Three Numbers — Program Statement Write a program to find the largest among three numbers. Concepts Covered - Chained comparisons and the built-in max() function
- 9. Give Grading Based on Their Marks — Program Statement Write a program to give grading based on their marks. Grading Scheme Marks Grade ------- ------- = 90 A = 75 B = 60 C = 40 D < 40 F (Fail)
- 10. Print if a Number is Leap Year or Not — Program Statement Write a program to print if a number is leap year or not. Rule A year is a leap year if it is divisible by 4, except century years, which must be divisible by…
- 11. Check Whether a Number is Armstrong Number or Not — Program Statement Write a program to check whether a number is Armstrong number or not. Concepts Covered - An Armstrong number equals the sum of its own digits each raised to the…
- 12. Find Sum of First N Natural Numbers — Program Statement Write a program to find sum of first N natural numbers. Concepts Covered - for loop accumulation - Cross-checking with the closed-form formula n(n+1)/2
- 13. Check if a Number is Prime or Not — Program Statement Write a program to check if a number is prime or not. Concepts Covered - Trial division up to sqrt(n) for efficiency
- 14. Print Fibonacci Series — Program Statement Write a program to print Fibonacci series. Concepts Covered - Each term is the sum of the previous two: 0, 1, 1, 2, 3, 5, 8, ...
- 15. Print Multiplication Table of a Number — Program Statement Write a program to print multiplication table of a number.
- 16. Print Factorial of a Number — Program Statement Write a program to print factorial of a number. Concepts Covered - Iterative factorial computation - Cross-checking with math.factorial()
- 17. Print Reverse of a Number — Program Statement Write a program to print reverse of a number. Concepts Covered - Digit extraction using % and // - A one-line string-slice alternative
- 18. Illustrate the Use of Break and Continue in Loops — Program Statement Write a program to illustrate the use of break and continue in loops. Concepts Covered - break exits the loop entirely - continue skips to the next iteration
- 19. Calculate Power of a Number — Program Statement Write a program to calculate power of a number. Concepts Covered - The operator vs manual loop-based exponentiation vs pow()
- 20. Print Numbers Divisible by 3 and 5 Between 1 and 100 — Program Statement Write a program to print numbers divisible by 3 and 5 between 1 and 100.
- 21. Star Patterns — Increasing and Decreasing Triangle — Program Statement Write a python program to perform the following patterns: 1. A right triangle of stars that grows one row at a time ( up to ) 2. The mirror image — a triangle…
- 22. String Slicing Operations — Program Statement Write a python program to perform the following string slicing operations. Concepts Covered - Slice syntax s[start:stop:step] - Reversal, sub-strings, and…
- 23. Five Number/Letter Patterns — Program Statement Write a python program to perform the following patterns: 1. A, A B, A B C, ... A B C D E (growing alphabet rows) 2. 1 / 2 2 / 3 3 3 / 4 4 4 4 / 5 5 5 5 5…
- 24. Calculate Area of Circle — Program Statement Write a python program to calculate area of circle. Concepts Covered - Formula: area = π r² - Using math.pi for precision
- 25. Check Whether the Letter is a Vowel or Not — Program Statement Write a python program to check whether the letter is a vowel or not. Concepts Covered - Membership test with the in operator
- 26. Enter a Number Between 1–7 and Display the Corresponding Day — Program Statement Write a python program that prompts the user to enter a number between 1 to 7 and then display the corresponding days of the week. Concepts Covered - Dictionary…
- 27. While Loop Countdown to Zero — Program Statement Write a python program using a while loop that asks the user for a number and prints its countdown to zero.
- 28. Demonstrate List Functions & Utility Functions — Program Statement Demonstrate the use of different list functions — append(), extend(), insert(), remove(), pop(), clear(), index(), count(), sort(), reverse() — and utility…
- 29. Use Lists as Stack and Queue — Program Statement Use Lists as stack and queue. Concepts Covered - Stack (LIFO): append() / pop() at the same end - Queue (FIFO): append() at one end, pop(0) from the other
- 30. Demonstrate List Slicing — Program Statement Demonstrate the use of list slicing.
- 31. Difference Between Lists and Tuples — Program Statement Show the difference between lists and tuples with appropriate examples. Key Difference List Tuple :--- :--- Mutable (can change) Immutable (cannot change) [ ]…
- 32. Cartesian Product of Two Lists & List Comprehension (Words > 4 Letters) — Program Statement (A) Perform Cartesian product of two lists using tuples. (B) Keep words in a list with length 4 using list comprehension.
- 33. Demonstrate All Dictionary Methods — Program Statement Demonstrate the use of all dictionary methods using python: get(), items(), keys(), values(), update(), fromkeys(), pop(), popitem(), setdefault(), clear(),…
- 34. Employee Tuples — Zip, Filter, Sort, Add Position — Program Statement Write a program to create tuples namely emp name, designation and salary. Insert at least 5 records and perform the following operations: 1. Zip the tuples. 2.…
- 35. State-Code Dictionary with Default Value — Program Statement Write a program that has a dictionary of five states and their codes, for example: Delhi : DL, and perform the following: 1. Add 5 more states to the previous…
- 36. Intersection, Union, Difference, Symmetric Difference of Two Sets — Program Statement Write a program to find intersection, union, difference, symmetric difference between two sets.
- 37. Function to Perform Linear Search — Program Statement Write a function to perform linear search. Concepts Covered - Sequential scan, O(n) time complexity
- 38. Function to Perform Binary Search — Program Statement Write a function to perform binary search. Concepts Covered - Requires a sorted array; halves the search space each step, O(log n)
- 39. Demonstrate Different Types of Function Arguments — Program Statement Demonstrate the use of different types of arguments: positional, keyword, default, variable positional and variable keyword arguments.
- 40. Demonstrate Call by Value and Call by Reference — Program Statement Write a program to demonstrate the use of call by value and call by reference. Concepts Covered - Python passes references, but immutable objects (int, str,…
- 41. Create Local & Global Variable — Program Statement Write a program to create local & global variable. Concepts Covered - Variables declared inside a function are local by default - The global keyword lets a…
- 42. Access of Variable in Inner & Outer Function — Program Statement Write a program to demonstrate the access of variable in inner & outer function. Concepts Covered - A nested (inner) function can read the enclosing (outer)…
- 43. Print Factorial of a Number Using Function — Program Statement Write a program to print factorial of a number using function. Concepts Covered - Both an iterative and a recursive implementation
- 44. Use Different Types of Functions Within math Module — Program Statement Use different types of functions within math module.
- 45. Use Different Types of Functions Within random Module — Program Statement Use different types of functions within random module. Note Random output changes every run — that is expected behaviour for this module.
- 46. Create Class and Objects — Program Statement Write a python program to create class and objects. Concepts Covered - class , init constructor, instance methods, self
- 47. Copy the Contents of a File to Another File — Program Statement Write a program to copy the contents of a file to another file in a text file. Note This runs against the browser's in-memory filesystem, so it works with zero…
- 48. Return the Number of Words in a Given Text File — Program Statement Write a python program that takes a text file as input and return the number of words of a given file.
- 49. Text File Operations: Read, Check, Write, Append & Remove — Program Statement Create a text file and perform the following operations: 1. Open the file and read the content from the file. 2. Check the file if exists or not. 3. Write the…
- 50. Add a List to NumPy Array — Program Statement Write a program to add a list to Numpy Array.
- 51. Implement Various Operations on NumPy Array — Program Statement Write a program to implement various operations on NumPy array.
- 52. Matplotlib Pie Chart — Fruit Distribution — Program Statement Write a Python script using Matplotlib to create a pie chart that displays the distribution of fruits in a basket: 30 apples, 20 bananas, 25 oranges, and 15…
- 53. Matplotlib Bar Chart — Course Enrollment — Program Statement Create a bar chart using Matplotlib to display the number of students enrolled in different courses: Math (50), Science (40), History (30), and Art (20).
- 54. Bar Chart with Custom Colours, Tick Labels & Grid — Program Statement Create a bar chart that includes different colours for each bar, custom tick labels, and a grid.
Lab 0: Compiler Setup & Environment Check
Program Statement
Verify that the built-in Python compiler (Pyodide, running in your browser) is ready to run the Python Programming Lab practicals.
Compiler Info
| Property | Value |
|---|---|
| Runtime | Pyodide (CPython compiled to WebAssembly) |
| Packages | numpy, matplotlib auto-load when imported |
| I/O | Console (stdout), file I/O via an in-browser virtual filesystem |
How to Use
- Click RUN CODE to execute — no installation needed, it runs right in the browser tab.
- Programs that would normally use
input()use hardcoded sample values instead (commented alternative shown), so every practical runs with one click. Edit the values and re-run to test other cases. - Practicals that plot a chart (NumPy/Matplotlib, experiments 50–54) render the image directly below the console output.
Installing Python on Your Own Machine
For the actual lab record, install Python locally:
- Go to python.org/downloads and download the latest Python 3 installer for your OS.
- Run the installer — on Windows, tick "Add Python to PATH" before clicking Install.
- Verify from a terminal:
python --version. - Write code in IDLE (bundled with Python) or an editor like VS Code with the Python extension.
Continue reading: Lab 0: Compiler Setup & Environment Check →
Frequently asked questions
Is the Python Programming Lab course really free?
Yes. The entire Python Programming Lab course on Siksha Sarovar is free to read with no account required. You can optionally sign in with Google to save your progress.
Do I get a certificate for Python Programming Lab?
Yes — finish the lessons and pass the quiz to earn a free, verifiable certificate you can share on LinkedIn or with recruiters.
Can I run code while learning?
Yes. The built-in online compiler runs C, C++, Python, Java, PHP, JavaScript, C# and SQL directly in your browser — no installation needed.