Gautam Python Worksheet
Gautam Python Worksheet
Q. (a) Write a python program to generate histogram using matplotlib. The graph should
be properly labelled.
Aim/Overview of the practical: The aim of this practical is to understand the basic concept of
plotting histogram using matplotlib. This will enhace your analytical skills.
1. Task to be done:
• First we have to import the matplotlib library.
• Secondly,we have to define the data.
• Then we have to crate histogram and adding labels and title into it.
• Lastly, we have to display the histogram.
2. Code for experiment/practical:
import numpy as np
# Sample data
plt.ylabel('marks')
plt.title('Histogram of result')
plt.show()
3. Result/Output/Writing Summary:
Learned to plot the histogram and applying some themes on it like color and border etc.
Aim/Overview of the practical: The aim of this practical is to understand how to plot
mathematical functions using Python's matplotlib library. the function y = x2 is plotted, which
will allow you to visualize the behavior of the quadratic equation.
1. Task to be done:
• Firstly, we have to import the matplotlib library.
• Then we have to generate data points and calculate y values.
• Then we have to plot the function and add labels and title to it.’
• Lastly, we have to display the data.
# Add a legend
plt.legend()
plt.grid(False)
plt.show()
3.Result/Output/Writing Summary:
• Learning outcomes (What I have learnt):
• Learned how to apply mathematical functions using python library.
• Get more familiarize with matplotlib library.
• Learned to visualize the behaviour of quadratic equation.
• Understand the basic use of numpy for basic use of numerical operations.