PYTHON
1. Write a Python pandas code for the following questions:
i. To create the dictionary data of the above table and print the dictionary.
ii. To create the data frame from the dictionary data.
iii. To add the new column Total which is the sum of Score1 and Score2
and print the column Total.
iv. To print the maximum score from the score1 column
v. Create a CSV file [Link] using this data frame.
vi. To create the line graph for Score1, Score2 and Total using the data stored
in the CSV file, [Link]. Use appropriate title.
Code:
import pandas as pd
import [Link] as plt
data={'B_NO':[1,2,3,4],'Name':["Sunil Pillai","Gaurav Sharma","Piyush Goel","Kartik
Thakur"],'Score1':[90,65,70,80],
'Score2':[80,45,95,76]}
df=[Link](data)
print(df)
df['Total'] = df['Score1']+ df['Score2']
print(df)
print(df['Total'])
print(max(df.Score1))
#Importing/Exporting DataFrame from/to csv file
df.to_csv(r'C:\Users\admin\Desktop\[Link]')
#Exporting DataFrame data to csv file
data = pd.read_csv (r'C:\Users\admin\Desktop\[Link]',usecols = ['Score1','Score2','Total'])
print(data)
[Link](marker=’o',markersize=10,figsize=(6,6))
[Link]("Marks")
[Link]()
Output:
2. Create a dataframe SalesPerson stored as a dictionary and containing the following
data: (8 Marks)
Id Name Age Salary
1 Ajay 61 140000
2 Sunil 34 44000
5 Chris 34 40000
7 Anaaya 41 52000
i. To create the data frame from the dictionary data and print the data frame.
iii. To add the new column Bonus which is 30% of the column Salary column and print
the column Bonus.
iv. To print the maximum value from Salary column.
v. Transfer the above created dataframe into csv file [Link]
vi. To create the line graph for Age, Salary, and Bonus using the data stored
in the csv file, [Link].
Code:
import pandas as pd
import [Link] as plt
data={'Id':[1,2,5,7], 'Name':["Ajay","Sunil","Chris","Amaaya"],'Age':[61,34,34,41],
'Salary':[140000,44000,40000,52000]}
SalesPerson=[Link](data)
print(SalesPerson)
SalesPerson['Bonus'] = 0.30*SalesPerson['Salary']
print(SalesPerson['Bonus'])
print(max([Link]))
#Importing/Exporting DataFrame from/to CSV file
SalesPerson.to_csv(r'C:\Users\admin\Desktop\[Link]')
#Exporting DataFrame data to csv file
data = pd.read_csv (r'C:\Users\admin\Desktop\[Link]', usecols = ['Age','Salary','Bonus'])
print(data)
[Link](marker='o',markersize=10,figsize=(6,6))
[Link]("Sales")
[Link]()
Output:
3. Create a dataframe SalesPerson stored as a dictionary and containing the following
data: (8 Marks)
Id Name Age Salary
1 Ajay 61 140000
2 Sunil 34 44000
5 Chris 34 40000
7 Anaaya 41 52000
i. To create the data frame from the dictionary data and print the data frame.
iii. To add the new column Bonus which is 30% of the column Salary column and print
the column Bonus.
iv. To print the maximum value from Salary column.
v. Transfer the above created dataframe into csv file [Link]
vi. To create the bar graph for Age, Salary using the data stored
in the csv file, [Link].
Code:
import pandas as pd
import [Link] as plt
data={'Id':[1,2,5,7], 'Name':["Ajay","Sunil","Chris","Amaaya"],'Age':[61,34,34,41],
'Salary':[140000,44000,40000,52000]}
SalesPerson=[Link](data)
print(SalesPerson)
SalesPerson['Bonus'] = 0.30*Salesperson['Salary']
print(SalesPerson['Bonus'])
print(max([Link]))
#Importing/Exporting DataFrame from/to CSV file
SalesPerson.to_csv(r'C:\Users\admin\Desktop\[Link]')
#Exporting DataFrame data to csv file
data = pd.read_csv (r'C:\Users\admin\Desktop\[Link]',usecols = ['Age','Salary'])
print(data)
x=data['Age']
y=data['Salary']
[Link]('Age')
#Assingning Data for Y axis
[Link]('Salary')
[Link](x,y,color='Blue', width=.50)
[Link]("Sales")
[Link]()
Output:
[Link] a Panda series from a dictionary of values containing month names and the number of days
within. Write a Python program to perform the following operations:
a) Create the series and display it.
b) Reverse the entire series.
c) Create a dataframe df from the above series.
d) Transfer the above created dataframe into CSV file [Link].
e) Create a data frame from the imported csv file [Link] data.
5. The table shows passenger car fuel rates in miles per gallon for several years. Make a LINE
GRAPH of the data. During which 2-year period did the fuel rate decrease? (3)
YEAR: 2000 2002 2004 2006
RATE: 21.0 20.7 21.2 21.6
6. The number of bed-sheets manufactured by a factory during five consecutive weeks
is given below. (3)
Week First Second Third Fourth Fift
h
Number of Bed- 600 850 700 300 900
sheets
Draw the bar graph representing the above data
MYSQL
1. Consider the table given below and write the query for the following Table:
CLUB
a) To display the name of all games with their Gcodes
b) To display the details of those games which are having fees more than 7000
c) To display the content of the CLUB table in descending order of start date
d) To delete the record of all GameNames
e) List the minimum and maximum fees from CLUB
2. Consider a table EMPLOYEE with the following data and answer the SQL queries:
(7 Marks)
ENO ENAME SALARY AREA BONUS DATE OF JOIN
CODE
1 Raj Sinha 3000.50 36 12.00 19-07-2009
2 Udit Thakur 5000.45 48 10.00 22-03-2008
3 R. K. Sharma 3000.23 36 NULL 08-03-2007
4 Neha Yadav 8000.75 60 10.00 06-12-2008
5 Ajay Garg 2000.75 36 12.50 03-01-2010
6 Ravi Ranjan 7000.50 60 12.50 05-06-2008
7 Mohit Dua 5000.00 48 NULL 05-03-2008
a. Display records where bonus is not null.
b. Display the maximum and minimum salary of employees.
c. Display the number of employees and sum of salary of employees in in each area.
d. Display the names of employees in upper case and lower case.
e. Display the salary of employees rounded to zero decimal places.
All the best . ‘Avalathan po nambala mudichivitanga ’