Unit 5- Python
Unit 5- Python
Python Programming
(BCC-402)
UNIT -5
Syllabus
Introduction to Matplotlib
What is Matplotlib?
Widely used in data science for plotting data, simple interface, and highly
customizable.
Installing Matplotlib:
Line Plots:
The simplest plot type, used to display data points connected by lines.
Adding Legends:
Plot Styles
Available Styles:
Applying Styles:
plt.style.use('ggplot')
Purpose of Annotations:
Highlight important data points or areas in the plot.
Saving Figures
Saving Plots as Images:
Different Formats:
Approach:
Use line plots, bar charts, and histograms to represent different aspects of the
data.
Numpy
What is Numpy?
Key Features:
Example Code:
Multi-dimensional Arrays
Content:
Understanding Broadcasting
What is Broadcasting?
Numpy Performance
Comparing Numpy Arrays with Python Lists:
Numpy arrays are implemented in C and are much faster for numerical operations
compared to Python lists.
Numpy operations are vectorized, meaning they can apply operations across
entire arrays without the need for explicit loops.
Approach:
Use Numpy to efficiently calculate the position of the projectile at each time step.
Pandas
What is Pandas?
A powerful library for data manipulation and analysis, built on top of Numpy.
Installing Pandas:
Dataframes
Creating DataFrames:
Data Importing
Reading from CSV:
One of the most common data formats. Pandas makes it easy to read CSV files
into DataFrames.
Example Code:
Removing Duplicates:
Grouping Data:
Approach:
Step 2: Perform data cleaning to handle missing values and correct data types.
Step 3: Analyze sales trends by grouping data by time, products, and regions.
Step 4: Visualize key metrics such as total sales, average sales per customer, and
sales distribution across different products.
Course Code: BCC 302 Course Name: Python Programming
Department of CSE- Artificial Intelligence and Machine Learning
Tkinter
What is Tkinter?
Tkinter is Python’s standard library for creating Graphical User Interfaces (GUIs).
It’s easy to use and comes with Python out of the box. Suitable for simple GUI
applications.
Installing Tkinter:
Tk() initializes the Tkinter window, and mainloop() keeps the window open until
manually closed.
Events in Tkinter include button clicks, key presses, and mouse movements.
Binding Events:
Widgets in Tkinter are the elements of GUI application which provides various
controls (such as Labels, Buttons, ComboBoxes, CheckBoxes, MenuBars,
RadioButtons and many more) to users to interact with the application.
Canvas It is used to draw pictures and others layouts like texts, graphics etc.
It displays a number of options to the user as toggle buttons from which user can select any
CheckButton
number of options.
RadioButton It is used to implement one-of-many selection as it allows only one option to be selected
Message It works same as that of label and refers to multi-line and non-editable text
Scale It is used to provide a graphical slider which allows to select any value from that scale
Text It allows user to edit multiline text and format the way it has to be displayed
Course Code: BCC
Menu 302 Course
It is used to create Name:
all kinds of menuPython Programming
used by an application
Department of CSE- Artificial Intelligence and Machine Learning
Build a basic calculator with buttons for digits, operations, and a display for the
result.
Steps:
IDEs
Here is the list of Top Python IDEs for 2024:
PyCharm
IDLE
Visual Studio Code
Atom
Sublime Text
Spyder
PyDev
Jupyter
Thonny
PyScripter
PyCharm
PyCharm is an Integrated Development Environment specifically for the development of applications in Python and Java.
Its functionalities include analysis of the code, a graphical debugger, etc. PyCharm helps to easily connect with a
database. It contains an integrated unit tester and other testing frameworks such as pytest, nose, doctest, tox, and trial.
PyCharm has got a lot of shortcuts to search and navigate different files and projects
IDLE
IDLE (Integrated Development and Learning Environment) is a dedicated platform or software to develop Python
applications. It is a full-fledged editor that is used to create, modify, and execute python code. It can also be used like the
Python Shell to execute single statements.
Visual Studio Code referred to as VS Code is a lightweight source code editor used to develop projects in various
programming languages such as Python, HTML, C, C#, JavaScript, etc. The User Interface is well-documented and user-
friendly with custom themes.
Jupyter
Jupyter Notebook is another Integrated Development Environment specifically used for Data Science. It
can be executed on a local desktop or can be installed on a remote server. Installing Anaconda would
be the first step, to begin with in using Jupyter. It is an interactive computational environment.
Pandas, Matplotlib, Seaborn, Numpy, etc. could easily work with data and plot charts. The documents
created in Jupyter might contain visualizations, equations, narrative text, etc. Jupyter is open-sourced
and free to use.
PyScripter
PyScripter is a lightweight Integrated Development Platform designed specifically for Python. Integrated
Python Interpreter, Syntax highlighting, Integrated testing framework, regular expression testing, find
and replace options, debugging, etc. are the few features that stand out.
Thank You