Assignment 4 Informatics Practices
Akavira kesar XII-B
Q1.
Input
import matplotlib.pyplot as plt
l=[1,2,4,3,0]
plt.plot(l)
plt.show()
Output
Q2.
Input
import matplotlib.pyplot as plt
import numpy as np
x=np.arange(2,11,2)
y=x**2
plt.xlabel("Numbers")
plt.ylabel("Square of numbers")
plt.title("square of given numbers")
plt.plot(x,y, marker='o')
plt.show()
output
Q3.
Input
import matplotlib.pyplot as plt
year=[1960,1970,1980,1990,2000,2010]
pop_pak=[44.91,58.09,78.07,107.7,138.5,170.6]
pop_in=[449.48,553.57,696.783,870.133,1000.4,1309.1]
plt.xlabel("year")
plt.ylabel("Population")
plt.title("Comparison of population")
plt.plot(year,pop_in,color="r",label="India")
plt.plot(year,pop_pak,color="g",marker='o',label="Pakistan")
plt.grid()
plt.show()
Output
Q4.
Input
import matplotlib.pyplot as plt
days=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday']
t_sold=[2000,2800,3000,2500,2300,2500,1000]
plt.xlabel("Days")
plt.ylabel("Tickets Sold")
plt.title("Tickets sold each day")
plt.plot(days,t_sold,color="r",marker="+",markersize=10)
plt.legend()
plt.show()
Output
Q5.
Input
import matplotlib.pyplot as plt
import pandas as pd
df=pd.read_csv("temp.csv")
print(df)
c=df["Day"]
a=df["Min_Temp"]
b=df["Max_Temp"]
plt.ylabel("Temperature in Celcius")
plt.xlabel("Days")
plt.title("Plotting data from csv file")
plt.plot(c,a,label="Min Temp",marker =".",markeredgecolor="k")
plt.plot(c,b,label="Max Temp",marker ="x",markeredgecolor="k")
plt.legend()
plt.show()
Output
======= RESTART: C:/Users/Akavira kesar/OneDrive/Desktop/IP XII/A-3/Q5.py ======
Day Min_Temp Max_Temp
0 1 29.0 44.0
1 2 28.5 43.5
2 3 28.0 43.0
3 4 31.0 44.5
4 5 27.0 42.0
5 6 27.5 42.5
6 7 27.0 43.0
Q6.
Input
import matplotlib.pyplot as plt
L=[4,12,10,2]
L1=['A','B','C','D']
plt.xlabel("Grades")
plt.ylabel("No. of students")
plt.title("Number of students in each grade")
plt.barh(L1,L)
plt.show()
Output
Q7.
Input
import matplotlib.pyplot as plt
Years=[2015,2016,2017,2018]
perc=[80,80,80,90]
plt.xlabel("Years")
plt.ylabel("Pass percentage")
plt.title("CBSE 2015 to 2018")
plt.bar(Years,perc)
plt.show()
Output
Q8
Input
import matplotlib.pyplot as plt
patient_age=[4,9,33,44,23,30,37,40,41,41,44,45,51,52,55,60,61,61,62,72,64,68,7,71,72,74,76,77,79,80,82,85]
age_group=[0,10,20,30,40,50,60,70,80,90]
plt.hist(patient_age,bins=age_group,color='y',edgecolor='b')
plt.xlabel("No. of patients")
plt.ylabel("Age group")
plt.title("Data of covid patients in various ages")
plt.show()
Output
Q9.
Input
import matplotlib.pyplot as plt
ip_marks=[51,57,66,64,63,67,77,74,73,79,78,76,89,87,85,83,99]
marks=[50,60,70,80,90,100]
plt.xlabel("Marks")
plt.ylabel("Frequency of distribution of marks")
plt.title("Bar type histogram of IP marks")
plt.hist(ip_marks,bins=marks,color='g',label="IP Test Data",edgecolor='b')
plt.legend()
plt.show()
Output
Q.10
Input
import matplotlib.pyplot as plt
l=[53,55,61,65,67,68,71,72,73,74,75,76,81,82,83,91,97]
l1=[50,60,70,80,90,100]
plt.xlabel("Marks")
plt.ylabel("Frequency of Distribution Of Marks")
plt.title("Step Type Histogram of IP Marks")
plt.hist(l,l1,label="IP Test Data",histtype="step")
plt.xticks(rotation=30)
plt.legend(loc="upper left")
plt.show()
Output
Q.11
Input
import pandas as pd
import matplotlib.pyplot as plt
d={1995:[52,64,78,94],2005:[340,480,688,766],2015:[890,560,1102,889]}
df=pd.DataFrame(d,index=['a','b','c','d'])
print(df)
l1=df[1995]
l2=df[2005]
l3=df[2015]
x=['a','b','c','d']
plt.xlabel("Users")
plt.ylabel("Values")
plt.title("Multi Range Line Chart")
plt.plot(x,l1,label="1995",marker=".",markeredgecolor='k')
plt.plot(x,l2,label="2005",marker=".",markeredgecolor='k')
plt.plot(x,l3,label="2015",marker=".",markeredgecolor='k')
plt.legend()
plt.show()
Output
====== RESTART: C:/Users/Akavira kesar/OneDrive/Desktop/IP XII/A-3/Q11.py ======
1995 2005 2015
a 52 340 890
b 64 480 560
c 78 688 1102
d 94 766 889