Professional Documents
Culture Documents
Practical File (Edited) 5
Practical File (Edited) 5
___________________ ___________________
Signature of Teacher Signature of External
Index
MYSQL:
→ Create a Database ‘School’ on the database server
→ create the following table named ‘STUDENT’
→ insert the following records into the table
→ Display info of males whose city, is neither Delhi nor Mumbai
→ display name, marks and round up the square root of marks up to two decimal places
Pandas (Series):
→ Create a panda's series from a dictionary of values and a ndarray or predefined array.
→ Showing series various attributes
→Write a Program to show the utility of head and tail functions of Panda series in python.
→ Mathematical operations on series
Pandas (DataFrame):
→ Write a Program to enter data and show data in python using dataFrames.
Visualisation (Matplotlib):
→ Write a program to plot bar chart having Cities along with their Population on x-axis and y-axis.
→ Write a program to plot a line chart with title,xlabel, ylabel and line style.
→ Write a program to plot line chart showing sales of different items in a month.
→ Write a program to display the runs scored by different batsman in a tournament
→ Make a histogram to show the comparison between blood sugar levels of men
MYSQL:
→ Create a Database ‘School’ on the database server,show the list
of databases and open it
Solution:
Solution:
→ Display name and marks of students whose marks is in the range
of 400 and 500(both are exclusive)
Solution:
Output:
Output:
→Write a Program to show the utility of head and tail functions of
Panda series in python.
Code:
import pandas as pd
#utility of head and tail functions in series
s1=pd.Series([20,28,31,14,17], index=["p","q","r","s","t"])
#to get the last two rows
print(s1.tail(2))
#to get the first 3 rows
print(s1.head(3))
Output:
print(s2*2)
print(s2+s3)
print(s2/s3)
Output:
→Selection, indexing and slicing in series
Code:
import pandas as pd
#selecting,indexing and slicing in series
s1=pd.Series([18,28,26,19,41],index=['a','b','c','d','e'])
s2=pd.Series([10,15,23,35,12],index=['p','q','r','s','t'])
print(s1[3])
print(s2[2:6])
Output:
(DATAFRAME)
→Write a Program to enter data and show data in python using
dataFrames .
Code:
import pandas as pd
#entering and showing data in dataframe
dict1={2020:[102.3,152.6,203.9,20000,35000],2021:[13500,19540,22000,25000,45000
],2022:[15000,45000,56000,100400,135000],2023:[50000,60000,70000,80000,90000]}
sales =pd.DataFrame(dict1,index=['yash','yachak','garima','jatin','akansha'])
print(sales)
Output:
Output:
→Write a python program to read CSV file and show its data in
python using dataFrames and pandas.
Code:
import pandas as pd
L1=['p101','yash',60]
L2=['p102','yachak',61]
L3=['p103','jatin',73]
L4=['p104','aksh',52]
Df1=pd.DataFrame([L1,L2,L3,L4],columns=['Pcode','name','marks'])
#dataframe to csv
Df1.to_csv('ip.csv')
#csv to dataframe
ab=pd.read_csv('ip.csv')
print(ab)
Output:
Output:
Output:
Matplotlib
→Write a python program to plot bar chart having cities along with
their population on xaxis and yaxis
Code:
import matplotlib.pyplot as plt
City=['Haryana','Delhi','Mumbai','Tamil Nadu','Chennai']
Population=[400,200,600,900,1200]
plt.bar(City,Population)
plt.show()
Output:
Name=['Yash','Yachak','Jatin','Rishika','Akansha','shrishti','Bhumika','Anshika']
Age=[16,17,14,12,10,6,13,9]
plt.plot(Name,Age,linestyle=':',color='red')
plt.xlabel('name of children')
plt.ylabel('age in years')
plt.show()
Output:
→Write a program to plot a line chart showing sales of different
items in a month
Code:
import matplotlib.pyplot as plt
plt.figure(figsize=(9,5))
i_name=['angry bird','teentitan','marvel comics','colorme','wapppro','maths
formula','drag race']
sale=[80,120,40,550,60,30,130]
plt.plot(i_name,sale,linewidth=2,color='orange',marker='*',markersize=10,linestyle=':')
plt.xlabel('item_name')
plt.ylabel('per month sale')
plt.show()
Output:
Output:
Output: