ЁЯТ╗
тМия╕П
ЁЯЦ▒я╕П
ЁЯЦея╕П
ЁЯТ╛
тЖР Back to Dashboard
Font Size:

1. Introduction

The practical component of Class 11 Informatic Practices is where theoretical concepts come alive. In the laboratory, a student writes Python programs, executes SQL queries, and builds data visualisations, demonstrating that they can actually apply what they have learned. The practical exam typically consists of writing programs, running them, answering questions based on the output, and completing a project.

A good practical student is systematic: they read the problem carefully, plan the solution, write clean and readable code, test it with sample inputs, and handle errors gracefully. The most common sources of lost marks in practicals are careless syntax errors, wrong indentation, missing imports, and an inability to predict output or trace errors. This chapter consolidates everything learned in the previous chapters into a practical, exam-ready skill set.

We will work through complete example programs for common practical problems, study error handling with try and except, learn debugging techniques, and review the typical structure of a practical file. We will also list the standard programs and SQL queries a student is expected to practise before the examination. This chapter is the bridge between knowing concepts and demonstrating skill.

2. Python Programs: The Standard Recipe

Most practical Python programs follow the same structure:

  1. Accept input using input() and convert types if needed.
  2. Process the data using operators, conditions, and loops.
  3. Store results in variables, lists, or dictionaries.
  4. Display output using print().
def find_average(marks):
    total = sum(marks)
    count = len(marks)
    return total / count

marks_list = []
n = int(input("Enter number of students: "))
for i in range(n):
    m = int(input("Enter marks: "))
    marks_list.append(m)

avg = find_average(marks_list)
print("Average marks:", avg)

Common practical programs to practise

3. Handling Errors with try and except

Real programs receive unexpected input. Python raises exceptions, and the try and except block prevents the program from crashing:

try:
    num = int(input("Enter a number: "))
    print("You entered", num)
except ValueError:
    print("That was not a valid number")

The try block contains the risky code; if a ValueError occurs, control jumps to the matching except block. The else block runs if no error occurred, and finally runs always.

try:
    a = int(input("a: "))
    b = int(input("b: "))
    result = a / b
except ZeroDivisionError:
    print("Cannot divide by zero")
except ValueError:
    print("Invalid number entered")
else:
    print("Result:", result)
finally:
    print("Program finished")

4. Common Python Errors and Debugging

Debugging techniques

5. Data Visualisation Practical

A typical visualisation practical provides data and asks for a chart. The recipe is always the same:

import matplotlib.pyplot as plt

subjects = ["Maths", "Science", "English", "IP"]
marks = [85, 78, 92, 88]

plt.bar(subjects, marks, color="blue")
plt.title("Marks in Subjects")
plt.xlabel("Subjects")
plt.ylabel("Marks")
plt.show()

The examiner may ask for a line chart for trends, a bar chart for comparison, or a pie chart for proportions. Remember to include the import statement, all labels, and plt.show().

6. MySQL Practical

For MySQL practicals, the flow is: connect, create database, create table, insert sample data, and then answer queries.

CREATE DATABASE school;
USE school;

CREATE TABLE student (
    roll INT PRIMARY KEY,
    name VARCHAR(30),
    marks DECIMAL(5,2),
    city VARCHAR(20)
);

INSERT INTO student VALUES (1, 'Aarav', 89, 'Delhi');
INSERT INTO student VALUES (2, 'Bina', 94, 'Mumbai');

SELECT name, marks FROM student WHERE marks > 85 ORDER BY marks DESC;

The examiner may ask for specific queries such as counting records, finding maximum marks, filtering by city, or grouping by city with an aggregate.

7. Writing the Practical File

A good practical file contains for every program: 1. Aim and objective. 2. Algorithm or steps. 3. Source code with proper comments. 4. Sample input and output. 5. Conclusion.

Following a consistent format impresses examiners and makes the file easy to evaluate. At the end, include the project work and the SQL query sheets.

8. Time Management in the Practical Exam

9. Sample Programs Explained in Detail

The prime-checking program is a favourite practical question. The idea is to test whether a number has any divisor other than 1 and itself. A loop runs from 2 up to half of the number, and if the number is exactly divisible by any value in that range, a flag is set to show that the number is not prime. The program must handle the special cases 0 and 1 first, since neither is prime. Writing the condition for the loop and updating the flag correctly are the two steps where students lose marks, so the logic deserves careful attention and a few sample tests before it is recorded in the practical file.

The word-frequency program combines dictionaries with string handling. The sentence is read with input(), converted to lower case, split into words using the split() method, and then each word is counted with a dictionary exactly as described in the dictionary chapter. This program is a favourite because it ties together several chapters at once: strings, lists, dictionaries, and loops. It demonstrates how the separate topics of the syllabus come together in a single, meaningful solution. Tracing such a program with a short sentence like "a cat and a dog" is an excellent way to prepare for output-prediction questions, since the examiner often gives a small input and asks what the program will print. By working through such programs completely before the examination, the student builds the confidence and speed that the practical test demands.

Quick Revision Tables

Table 1: Common Python Exceptions

Exception When It Occurs Example
SyntaxError Wrong syntax Missing colon
NameError Undefined variable print(x) without x
TypeError Incompatible types "a" + 5
ValueError Invalid value int("abc")
IndexError Index out of range lst[10] on short list
KeyError Missing dictionary key d["x"]
ZeroDivisionError Divide by zero 5 / 0

Table 2: Practical Recipe Summary

Task Key Steps
Python program Input, process, output with print()
Error handling try, except, else, finally
Visualisation Import plt, choose chart, labels, show()
MySQL CREATE, INSERT, SELECT with WHERE/ORDER BY
Practical file Aim, algorithm, code, input/output, conclusion

Mind Map

graph TD A["Practicals"] --> B["Python Programs"] A --> C["Error Handling"] A --> D["Debugging"] A --> E["Visualisation"] A --> F["MySQL"] A --> G["Practical File"] B --> B1["Input-Process-Output"] B --> B2["Loops, lists, dictionaries"] C --> C1["try-except"] C --> C2["else and finally"] D --> D1["Read traceback"] D --> D2["Test with samples"] E --> E1["Bar, line, pie charts"] F --> F1["CREATE, INSERT"] F --> F2["SELECT queries"] G --> G1["Aim, algorithm, code, output"]

Important Diagrams (SVG)

Diagram 1: Flow of Solving a Practical Program

Solving a Practical Program Read the problem Plan algorithm / steps Write clean Python code Test with sample input Output correct? Yes No Debug the code Check errors, fix and retest Record output Write sample output in file Golden Rule Always test before recording output

Diagram 2: Python Error Handling Flow

try-except-else-finally Flow try block Error raised? No Yes except block Handle the error gracefully else block Runs when no error occurred finally block Always runs in both cases Golden Rule finally runs whether an error occurred or not; it is ideal for cleanup tasks

Common Mistakes

  1. Forgetting the import statement for matplotlib before plotting.
  2. Not converting input() results to int() or float(), causing type errors.
  3. Ignoring the traceback's last line, which tells exactly which error and line to check.
  4. Writing try without except, which is a syntax error.
  5. Dividing by zero without handling ZeroDivisionError, crashing the program.
  6. Forgetting plt.show(), so the chart never appears.
  7. Not testing a program before copying its output into the practical file.
  8. Writing SQL queries without a semicolon or with unquoted string values.

Exam Tips

  1. Practise at least one program for each of: loops, lists, dictionaries, and visualisation.
  2. Memorise the recipe for charts: import, data, plot function, labels, title, show.
  3. Learn the names and fixes of the six common exceptions listed above.
  4. Practise tracing a given program to predict its output; this is a frequent practical question.
  5. Always keep your practical file neat with a consistent format for every program.
  6. Test every program with at least one sample input during the practical exam.

Conclusion

Practicals are where a student proves mastery of Python, matplotlib, and MySQL. The key to success is a systematic approach: understand the problem, plan the solution, write clean code, test thoroughly, and record the output properly. Error handling with try and except makes programs robust, and debugging skills turn failures into learning. The standard recipes for programs, charts, and SQL queries, once internalised, make any practical task manageable. By combining all the concepts from earlier chapters into complete working examples, this chapter prepares the student not only for the practical examination but also for confident problem solving in the real world.