انتقل إلى المحتوى
cookie

CBSE Class 12 Informatics Practices

Class 12 · CBSEComputer Science32 ملاحظة في 4 مجلدات، 163 KB

32 ملاحظات للمذاكرة لمادة CBSE Class 12 Computer Science، أعدّها cookie، في 4 أقسام تتبع موضوعات المنهج.

Notes for CBSE Class 12 Informatics Practices (065), in folders for the curriculum's four units in order: data handling with Pandas and Matplotlib, SQL queries, computer networks and societal impacts. Code is in Python and MySQL, with worked examples. Follows the 2026-27 curriculum. The project and practical file are not covered. Delete any folder your course leaves out once the notes are yours.

ما المحتوى؟

الملاحظة الأولى

Data handling using Pandas and data visualisation / Pandas, NumPy and Matplotlib

Python's standard library handles numbers, text and lists, but it has nothing for working with a table of data or for drawing a chart. Two third-party libraries fill those gaps, and a third sits underneath one of them.

LibraryWhat it is forUsual import
PandasHolding and analysing labelled data in one dimension (Series) or two (DataFrame)import pandas as pd
NumPyFast arrays of numbers, which Pandas is built onimport numpy as np
MatplotlibDrawing line plots, bar graphs, histograms and other chartsimport matplotlib.pyplot as plt

The names pd, np and plt are aliases. They are conventions, not requirements, but every example in this course uses them, and code written with a different alias must use that alias everywhere. A library has to be installed once on the computer (with pip install pandas) and imported in every program that uses it.

Pandas

Pandas (the name comes from "panel data") reads data from files such as CSV, keeps it in labelled structures, and offers operations that would take many lines of plain Python: selecting rows by a condition, adding columns, grouping and summarising, and handing the result to Matplotlib for plotting.

It has two main data structures.

  • A Series is a one-dimensional labelled array. It holds values of one data type and has an index that labels each value.
  • A DataFrame is a two-dimensional labelled structure, a table with rows and columns. Each column behaves like a Series, and the columns can have different data types.

NumPy arrays

NumPy's central object is the ndarray, an n-dimensional array. Unlike a Python list, every element of an ndarray has the same data type, and arithmetic is applied to the whole array at once.

import numpy as np

a = np.array([10, 20, 30, 40])
print(a)          # [10 20 30 40]
print(a * 2)      # [20 40 60 80]
print(a + 5)      # [15 25 35 45]
print(a.dtype)    # int64 on most systems

A list does not behave this way, because [10, 20] * 2 repeats the list and [10, 20] + 5 is an error. The array is created from a list (or a tuple) with np.array(), and if the list mixes integers and floats every element is converted to float, because the array has one data type.

b = np.array([1, 2.5, 3])
print(b)          # [1.  2.5 3. ]

An ndarray is one of the forms of data from which a Pandas Series can be built, which is why it matters here.

Matplotlib

Matplotlib is a plotting library, and its pyplot module provides functions in the style of a drawing program: each call adds something to the current figure, and plt.show() displays it. Line plots, bar graphs and histograms are drawn with plt.plot(), plt.bar() and plt.hist(), and labels, a title and a legend are added with further calls. Pandas also has plotting methods of its own, which use Matplotlib underneath.

Importing in a program

A typical data-handling program starts with the imports and then works through read, process and plot.

import pandas as pd
import matplotlib.pyplot as plt

df = pd.read_csv("marks.csv")
print(df.head())
df["Maths"].plot(kind="bar")
plt.show()

Two forms of import are accepted, and they differ in how names are written afterwards. import pandas as pd means every Pandas name is written pd.Series, pd.DataFrame and so on. from pandas import Series brings one name in directly, so it is written Series(...) with no prefix. The aliased form is the one to use, because it shows at a glance where each name comes from.

و31 أخرى: افتح أياً منها من القائمة أعلاه.

التقييمات

لا توجد مراجعات مكتوبة بعد. أضف هذه الملاحظات إلى مجموعتك، ويمكنك أن تكون أول من يكتب مراجعة.