Assignment 3 Informatics Practices
Assignment 3 Informatics Practices
Input
l=[1,2,4,3,0]
plt.plot(l)
plt.show()
Output
Q2.
Input
import numpy as np
x=np.arange(2,11,2)
y=x**2
plt.xlabel("Numbers")
plt.ylabel("Square of numbers")
plt.plot(x,y, marker='o')
plt.show()
output
Q3.
Input
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
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.plot(days,t_sold,color="r",marker="+",markersize=10)
plt.legend()
plt.show()
Output
Q5.
Input
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.legend()
plt.show()
Output
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
L=[4,12,10,2]
L1=['A','B','C','D']
plt.xlabel("Grades")
plt.ylabel("No. of students")
plt.barh(L1,L)
plt.show()
Output
Q7.
Input
Years=[2015,2016,2017,2018]
perc=[80,80,80,90]
plt.xlabel("Years")
plt.ylabel("Pass percentage")
plt.bar(Years,perc)
plt.show()
Output
Q8
Input
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.show()
Output
Q9.
Input
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.legend()
plt.show()
Output
Q.10
Input
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.xticks(rotation=30)
plt.legend(loc="upper left")
plt.show()
Output
Q.11
Input
import pandas as pd
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.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
a 52 340 890
b 64 480 560
c 78 688 1102
d 94 766 889