Yuvi Ip File
Yuvi Ip File
Practical File
Class 12
SQL/Python
SUBMITTED BY:
Yuvraj Gupta
XII-C
PYTHON
Q1 Write a program to create a series S to store a range
of values where the user gives the upper and the lower
limits. Let the indexes be default values.
Ans1 –
import pandas as pd
lower=int(input("Enter the lower limit"))
upper=int(input("Enter the upper limit"))
S=pd.Series(range(lower,upper))
print(S)
Q2. Create two series S1 and S2 (the way done in Q1).
Perform various
mathematical operations (+, - , *, /) on both the series.
Ans2-
import pandas as pd
lower=int(input("Enter the lower limit of the first
series"))
upper=int(input("Enter the upper limit of the first
series"))
S=pd.Series(range(lower,upper))
print(S)
lower=int(input("Enter the lower limit of the second
series"))
upper=int(input("Enter the upper limit of the second
series"))
S1=pd.Series(range(lower,upper))
print(S1)
while(True):
print("Select the operation:")
print("1. Addition")
print("2. Substraction")
print("3. Multiplication")
print("4. Division")
print("5. Exit")
ch=int(input("Enter choice:"))
if ch==1:
print(S+S1)
elif ch==2:
print(S-S1)
elif ch==3:
print(S*S1)
elif ch==4:
print(S/S1)
elif ch==5:
Break
INPUT-
OUTPUT-
Q3. Write a program to accept the name and salary of
n number of
employees and then create the series to store names
as indexes and salary as
the data. The program must accept the name of the
employee whose salary
needs to be changed and the new salary of the
employee and then update it
in Series.
Ans3:
import pandas as pd
n=int(input("How many employees"))
name=[]
sal=[]
for i in range(n):
a=input("Enter name:")
b=int(input("Enter salary"))
name=name+[a]
sal=sal+[b]
S=pd.Series(sal,index=name)
print(S)
chk=input("Enter the name of employee whose salary
needs to be changed")
new_sal=int(input("Enter the updated salary:"))
S[chk]=new_sal
print("the Series after updating the salry is\n",S)
INPUT-
OUTPUT-
INPUT-
OUTPUT-
Section B
DataFrames
Q5. Write a program in python to create the following
dataframe named
“DATA”storing the details of CLAT students:
(f) Display the name and city for all those candidates
where the score is between 800 and 1000
Input:
data.loc[data.score.between(800,1000)]
Output:
Q15. Bajaj Auto has given his sales figures of his North
and East Region for
the 1 st quarter of the financial year 2020. Present the
same in the form of bar
Graph.
Ans:
import matplotlib.pyplot as p
import pandas as pd
dict1={'name':['Pratikshya', 'Mehul', 'Sharthak',
'Vaishnavi'],
'Points1':[92,60,67,80],
'Points2':[90,65,50,76],
'location':['New
Delhi','Bihar','Haryana','Odisha']}
df=pd.DataFrame(dict1,index=[1,2,3,4])
print(df)
x=df['name']
y=df['Points1']
z=df['Points2']
p.plot(x,y, linestyle="-",label="Points 1")
p.plot(x,z, linestyle=":",label="Points 2")
p.title('Presenting Cricket scores for every sportssman')
p.xlabel('Name of
Sportsman',fontsize="14",color="green")
p.ylabel('Points',fontsize="14",color="green")
p.legend()
p.show()
Output:
MySQL
Q1. Create a student table with the student id, name, and
marks as attributes where the student id is the primary
key.
Answer:
Answer:
Answer:
Table : CONSIGNEE
CNEID CNID CNENAME CNEADDRESS CNECITY
MU05 ND01 RAHUL KISHORE 5,PARK MUMBAI
AVENUE
MU08 ND02 P DHIMANT 16/J,MOORE NEW
ENCLAVE DELHI
KO19 MU15 A P ROY 2 A,CENTRAL KOLKATA
AVENUE
MU32 ND02 S MITTAL P 245,AB MUMBAI
COLONY
ND48 MU50 B P JAIN 13,BLOCK D, A NEW
VIHAR DELHI
ANS: