CBSE 2026-27 · Class 12 · Code 065

Important IP Programs

Master your practical exams with our curated list of essential Python programs for Class 12 Informatics Practices. Click on any program to view the code, copy it, or run it instantly.

In each topic the programs go from Easy to Hard. A CBSE tag shows the paper or practical list a program comes from; Rare marks less common programs that are still in the syllabus.

70 programs in 12 topics

SERIES - CREATION 9 programs

  1. A Series is a one-column list with an index. Without your own index, pandas numbers the items 0, 1, 2 ...

    Easy
  2. Give each value a label with index=. Here the labels are month names.

  3. The dictionary keys become the index and the values become the data.

  4. One value repeated for every index label.

  5. Make a NumPy array with np.array(), then turn it into a Series.

  6. Complete-the-code question: the index holds the animal names.

  7. Create a Series from a dictionary of national parks and print the state of Sariska.

  8. Predict-the-output question: list * 2 repeats the list before the Series is made.

  9. Error-finding question. Mistakes fixed: Pandas -> pandas, [ ] -> { }, p.Series(s) -> pd.Series(stud).

SERIES - ATTRIBUTES, INDEXING & SLICING 7 programs

  1. head(n) shows the first n values and tail(n) the last n. Without n, both show 5.

    Easy
  2. Attributes describe the Series. They are written without brackets.

    Easy
  3. Use the label with loc[ ] and the position (from 0) with iloc[ ].

    Easy
  4. Predict-the-output question: s[1:3] gives positions 1 and 2 (the end position is not included).

  5. With labels, the end label IS included.

    Medium
  6. A condition in [ ] keeps only the values for which it is True.

    Medium
  7. quantile(0.75) gives the 75th percentile; then keep only the values above it.

SERIES - MATHEMATICAL OPERATIONS 5 programs

  1. The operation is done on every value of the Series.

    Easy
  2. Common functions that work on the whole Series.

    Easy
  3. Values with the same label are added together.

    Medium
  4. Predict-the-output question: a label found in only one Series gives NaN (no value).

  5. add() with fill_value=0 treats a missing label as 0 instead of giving NaN.

    Hard Rare

DATAFRAME - CREATION 7 programs

  1. Each key becomes a column name. (Corrected code: import, pd.DataFrame and print are in lowercase.)

  2. Each inner list is one row; columns= gives the column headings.

  3. Each dictionary is one row; its keys are the column names.

  4. index= gives each row its own label instead of 0, 1, 2 ...

  5. A key missing from one dictionary becomes NaN in that row.

  6. Each Series becomes one column.

  7. Complete-the-code question: all the Series use the same index 10, 16, 18.

DATAFRAME - ATTRIBUTES & DISPLAY 3 programs

  1. Create an exam result DataFrame and display the row labels, column labels, data types and dimensions.

  2. head()/tail() show the first/last rows; T swaps rows and columns.

    Easy
  3. Predict-the-output question: df.size counts all values; df[1:3] gives rows 1 and 2.

DATAFRAME - SELECTING DATA 6 programs

  1. df['col'] gives one column; df[['a', 'b']] (double brackets) gives many.

    Easy
  2. loc uses row labels; iloc uses positions counted from 0.

    Easy
  3. Give the row label and the column name.

    Easy
  4. Show which rows have more than 1 attempt, the last three records, and rows a and d.

  5. Put a condition inside df[ ] to keep only the rows where it is True.

  6. Join conditions with & (and) or | (or). Each condition needs its own brackets.

    Hard Rare

DATAFRAME - ADD, DELETE & RENAME 8 programs

  1. Assign a list to a new column name. The list must have one value per row.

  2. df.loc[new_label] = [values in column order].

  3. rename(columns={old: new}) returns a new DataFrame.

  4. drop(label) deletes a row; drop(name, axis=1) deletes a column.

  5. Three common changes to a DataFrame, one statement each.

  6. Print the first row, show one column, add a row, delete a column and rename a column.

  7. A new column can be calculated from other columns.

  8. rename(index={old: new}) changes row labels; df.index = [...] replaces all of them.

    Hard Rare

DATAFRAME - ITERATION & ANALYSIS 6 programs

  1. iterrows() gives the row label and the row, one row at a time.

    Easy
  2. items() gives the column name and the column, one column at a time.

    Easy
  3. duplicated() marks repeated rows; drop_duplicates() removes them.

  4. sort_values() arranges rows; ascending=False gives highest first.

    Medium Rare
  5. Group the rows by category and print the total expenditure of each category.

  6. Find the average, highest and lowest marks in each subject, and the topper.

IMPORT & EXPORT CSV FILES 6 programs

  1. to_csv() writes the DataFrame to a file. index=False leaves out the row numbers.

  2. The first line of the file becomes the column names.

  3. Error-finding question. Mistakes fixed: Pandas -> pandas, load_csv -> read_csv, sep="-" removed (values are separated by commas), data_frame -> df.

  4. sep= tells pandas which character separates the values, e.g. ; or |.

  5. header=None stops the first line being used as names; names= gives your own column names.

    Hard Rare
  6. Read a file, keep the rows you need, and export them to another file.

    Hard Rare

DATA VISUALIZATION - LINE PLOTS 5 programs

  1. plt.plot(x, y) joins the points with a line; plt.show() displays it.

    Easy
  2. Add a title and axis labels, and save the chart as a picture with savefig() before show().

  3. label= names the line and plt.legend() shows that name on the chart.

  4. color=, linestyle= and marker= change how the line looks.

    Medium
  5. Call plt.plot() twice; the legend tells the lines apart.

DATA VISUALIZATION - BAR GRAPHS 5 programs

  1. plt.bar(x, heights) draws one bar for each item.

  2. A bar chart with title, axis labels and savefig().

  3. color= and width= change the bars; plt.barh() draws them sideways.

    Medium
  4. Calculate averages with pandas, then plot them with title and legend.

  5. Shift the second set of bars a little to the right so both are visible.

    Hard Rare

DATA VISUALIZATION - HISTOGRAMS 3 programs

  1. A histogram shows how many values fall in each range (bin).

  2. bins= sets the ranges; edgecolor= outlines the bars.

  3. Use bins for grade ranges to see how many students got each grade band.

    Hard Rare