UNIT- 5
Python packages: Simple programs using the built-in functions of packages matplotlib, numpy, pandas etc.
Illustrative programs: create a pandas series using numpy, make a pandas data frame with 2D list. GUI
Programming: Tkinter introduction, Tkinter and Python Programming, Tk Widgets, Tkinter examples. Python
programming with IDE. Illustrative programs: create a GUI marksheet, calendar, file explorer using Tkinter.
Python Packages – Theory
What are Python Packages?
A package is a way of organizing related modules (Python files) into a single directory.
Packages make code reusable and organized.
Some common packages: numpy, pandas, matplotlib, tkinter
a) NumPy (Numerical Python)
NumPy is used for scientific computing with arrays and matrices.
It supports mathematical operations on large datasets efficiently.
Install:
pip install numpy
Common functions:
np.array(): Create arrays
np.arange(): Range of values
np.reshape(): Reshape array
np.mean(), np.median(), np.std(): Statistical functions
NumPy – Syntax & Examples
numpy.array()
Syntax:
numpy.array([elements])
Example:
import numpy as np
a = np.array([1, 2, 3])
print(a)
numpy.arange()
Syntax:
numpy.arange(start, stop, step)
Example:
import numpy as np
, a = np.arange(1, 10, 2)
print(a)
numpy.reshape()
Syntax:
array.reshape(rows, columns)
Example:
import numpy as np
a = np.array([1, 2, 3, 4, 5, 6])
b = a.reshape(2, 3)
print(b)
numpy.mean(), median(), std()
import numpy as np
a = np.array([10, 20, 30, 40])
print("Mean:", np.mean(a))
print("Median:", np.median(a))
print("Standard Deviation:", np.std(a))
b) Pandas
Pandas is a powerful package for data manipulation and analysis.
It uses two key data structures: Series (1D) and DataFrame (2D).
Install:
pip install pandas
Common uses:
pd.Series(): Create 1D labeled array
pd.DataFrame(): Create tabular data
.head(), .tail(): View data
.describe(), .info(): Data summary
2. Pandas – Syntax & Examples
pandas.Series()
Syntax:
pandas.Series(data)
Example:
import pandas as pd
import numpy as np
Python packages: Simple programs using the built-in functions of packages matplotlib, numpy, pandas etc.
Illustrative programs: create a pandas series using numpy, make a pandas data frame with 2D list. GUI
Programming: Tkinter introduction, Tkinter and Python Programming, Tk Widgets, Tkinter examples. Python
programming with IDE. Illustrative programs: create a GUI marksheet, calendar, file explorer using Tkinter.
Python Packages – Theory
What are Python Packages?
A package is a way of organizing related modules (Python files) into a single directory.
Packages make code reusable and organized.
Some common packages: numpy, pandas, matplotlib, tkinter
a) NumPy (Numerical Python)
NumPy is used for scientific computing with arrays and matrices.
It supports mathematical operations on large datasets efficiently.
Install:
pip install numpy
Common functions:
np.array(): Create arrays
np.arange(): Range of values
np.reshape(): Reshape array
np.mean(), np.median(), np.std(): Statistical functions
NumPy – Syntax & Examples
numpy.array()
Syntax:
numpy.array([elements])
Example:
import numpy as np
a = np.array([1, 2, 3])
print(a)
numpy.arange()
Syntax:
numpy.arange(start, stop, step)
Example:
import numpy as np
, a = np.arange(1, 10, 2)
print(a)
numpy.reshape()
Syntax:
array.reshape(rows, columns)
Example:
import numpy as np
a = np.array([1, 2, 3, 4, 5, 6])
b = a.reshape(2, 3)
print(b)
numpy.mean(), median(), std()
import numpy as np
a = np.array([10, 20, 30, 40])
print("Mean:", np.mean(a))
print("Median:", np.median(a))
print("Standard Deviation:", np.std(a))
b) Pandas
Pandas is a powerful package for data manipulation and analysis.
It uses two key data structures: Series (1D) and DataFrame (2D).
Install:
pip install pandas
Common uses:
pd.Series(): Create 1D labeled array
pd.DataFrame(): Create tabular data
.head(), .tail(): View data
.describe(), .info(): Data summary
2. Pandas – Syntax & Examples
pandas.Series()
Syntax:
pandas.Series(data)
Example:
import pandas as pd
import numpy as np