Download as pdf or txt
Download as pdf or txt
You are on page 1of 37

Question 1:

Write a program to create a pandas series from a dictionary of values and a ndarry.

Input

Output
Question 2:
Write a program to multiply and divide two Pandas Series.

Input

Output
Question 3:
Three series objects stores the marks of 10 students in three terms. Roll numbers of
students form the index of these Series objects.
The three series objects have the same indexes.
Write a Python Program to calculate the final marks obtained by students as per following
formula :Final marks = 25% term1 + 25% term2 + 50% term3
Store the final marks of students in another Series object.

Input

Output
Question 4:
Write a program to create a Series named S1 and display its type. Change the Series into a
list and display its type. Also display the elements of the Series which are above 20.

Input

Output
Question 5:
Write a program to change the order of index of a given series.
Original Data Series: A 1
B 2
C 3
dtype: int64
Data Series after changing the order of index
B 2
A 1
C 3
dtype: int64

Output
QUESTION 6:
Write a program to create and display a DataFrame from a specified dictionary with index
labels.

Input

Output
QUESTION 7:
Write a program to get the first 3 rows and last 4 rows of a given DataFrame

Input

Output
QUESTION 8:
Create a dataframe for examination result and display row labels, column labels, data types
of each column and the dimensions

Input

Output
QUESTION 9:
Write a program to create a Dataframe quarterly sales where each row contains the item
category, item name, and expenditure. Do the following tasks in the dataframe:
a) Display the itemname and expenditure columns
b) Display the rows where expenditure is more than 2500

Input

Output
Question 10:
Write a program to create a dataframe ‘data’ with the following details:

Write code to display the following:


a)Display city and favourite_color columns of first, fourth and seventh rows
b)Access value Chennai
c)Find rows where value of age is more than 16
d)Find rows where age is more than 13 and gender is Female
Input
Output
Question 11:
Write a Pandas program to count the number of rows and columns of a DataFrame
Input

Output
Question 12:
Write a program to import and export data between Pandas and CSV file.
Importing
Input

Output

Exporting

Input

Output
Question 13:
Write a Program to create a dataframe emp to hold empno, empname and salary details of 5
employees and perform the following tasks:(a)Add a column ‘Bonus’ which is calculated as
5% of salary.(b)Add a column ‘Dept’ between empname and salary columns and populate it
with appropriate values.(c)Remove the column ‘Bonus’.
Question 14:
Write a program to create dataframe ‘stock’ with the following data:

Write suitable python statements for the following


i. Add a column called Num_Copies with the following data:
[300,290,450,760].
ii. Add a new genre of type ‘Folk Tale' having code as “FT” and 600 number of
copies.
iii. Rename the column ‘Code’ to ‘Book_Code’.

Input

Output
Question 15:
Write a program to select the 'name' and 'score' columns from the following DataFrame.Also
change the score in row ‘d’ to 11.5
Sample DataFrame:
exam_data = {'name': ['Anastasia', 'Dima', 'Katherine', 'James', 'Emily', 'Michael', 'Matthew',
'Laura', 'Kevin', 'Jonas'],
'score': [12.5, 9, 16.5, np.nan, 9, 20, 14.5, np.nan, 8, 19],
'attempts': [1, 3, 2, 3, 2, 3, 1, 1, 2, 1],
'qualify': ['yes', 'no', 'yes', 'no', 'no', 'yes', 'yes', 'no', 'no', 'yes']}
labels = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']

Input
Output
Question 16:
A DataFrame 'item' has the following columns : pid,pname, price.

Write python statements for the following:


(a) Add a new column ‘qty’ with values 10,65,45,80
(b) Delete column price
(c) Delete the second row in the Dataframe
(d) Rename column qty to quantity
Input
Output
DATA VISUALIZATION

QUESTION 17:
Write a program to create a dataframe to store the school result data, analyses the
performance of the students on different parameters, e.g., subject wise or class wise.

Input
Question 18:
Given a dataframe df1 as shown below:

Write code to create,


(a)A line chart from the 1990 and 2000 columns of dataframe df1
(b)Create a bar chart plotting the three columns of dataframe df1
(a) Input
(b) Input
QUESTION 19:
Create a Dataframe quarterly_sales with columns Salesman, Sales, Quarter and District.
Write a program to draw a histogram based on monthly sales report for all numeric columns

Input
Question 20:
Consider the data given below:

Using the above data, plot the following


(a)A line chart depicting the prices of the apps
(b)A bar chart depicting the downloads of the apps
(c)Compute Estdownload sequence that has each download value divided by 1000.
Now create a bar chart that plots multiple barfor prices as well as Estdownloads
(d)The charts should have proper titles for the charts, axes, legends etc.
Input
MY SQL

Question 21:
(a) Create table Teacher in database school with the appropriate specification in
order to store the given data
(b) Populate the table with the following records

(c) Delete the details of ‘Mohan’. Undo the changes. Save the details permanently.
(d) Display all the Nonmedical stream students from the table
(e) List the names of those students who are in class 12 sorted by stipend
(f) List all students sorted by AvgMarks in descending order
(g) Display the average stipend of each stream
(h) Display the details of students who scored Avgmarks less than 75 and Grade is B
(i) Display the total stipend spent for class 12
(j) List the name and stream of students whose name contains letter ‘a’

a)
CREATE DATABASE SCHOOL;
CREATE TABLE STUDENT (No INT, Name VARCHAR(25), Stipend DECIMAL, Stream
VARCHAR(30), AvgMark DECIMAL, Grade VARCHAR(5), Class VARCHAR(10), PRIMARY
KEY(No));
b)
INSERT INTO student
-> VALUES(1, 'Karan', 400.00, 'Medical', 78.5, 'B', '12B');
INSERT INTO student
-> VALUES(2, 'Divakar', 450.00, 'Commerce', 89.2, 'A', '11C');
INSERT INTO student
-> VALUES(3, 'Divya', 300.00, 'Commerce', 68.6, 'C', '12C');
INSERT INTO student
-> VALUES(4, 'Arun', 350.00, 'Humanities', 73.1, 'B', '12C');
INSERT INTO student
-> VALUES(5, 'Sabina', 500.00, 'Nonmedical', 90.6, 'A', '11A' );
INSERT INTO student
-> VALUES(6, 'John', 400.00, 'Medical', 75.4, 'B', '12B');
INSERT INTO student
-> VALUES(7, 'Robert' , 250.00, 'Humanites', 64.4, 'C', '11A');
INSERT INTO student
-> VALUES(8, 'Rubina', 450.00, 'Nonmedical', 88.5, 'A', '12A');
INSERT INTO student
-> VALUES(9, 'Vikas', 500.00, 'Nonmedical', 92.0, 'A', '12A');
INSERT INTO student
-> VALUES(10, 'Mohan', 300.00, 'Commerce', 67.5, 'C', '12C');

(c) Delete the details of ‘Mohan’. Undo the changes. Save the details permanently.
(d) Display all the Nonmedical stream students from the table

(e) List the names of those students who are in class 12 sorted by stipend

(f) List all students sorted by AvgMarks in descending order

(g) Display the average stipend of each stream


(h) Display the details of students who scored Avgmarks less than 75 and Grade is B

(i) Display the total stipend spent for class 12

(j) List the name and stream of students whose name contains letter ‘a’

(k) List the details of students whose grade is either A or C


(l) Display No, Name and Class of students whose score is in the range 60 to 80

(m) Display the different streams in the table

(n) Display the number of students in each stream

(o) List the details of students who are not in the Humanities stream
Question 22:
(a) Create table Teacher in database school with the appropriate specification in order to
store the given data
b) Insert the given records into the table

(c) Display all information about teachers of PGT category


(d) To list the names of female teachers of Hindi Department
(e) To list names, departments and date of hiring of all teachers in ascending order of
date of hiring
(f) To count the number of teachers in English department
(g) To list the teachers details whose name starts with letter ‘s’
(h) Display gender wise average salaries
(i) Display total salary of each category
(j) To list the details of teachers who joined in year 1980
(k) Display the name, department and category of teachers whose salary is less than
23000
(l) Add a new column Bonus to the tableand Compute the Bonus as 10% of Salary
(m) Display the name and department of teachers whose name does not contain
letter ‘r’
(n) Display the details of teachers in ascending order of Category , then descending
order of Salary
(o) Display the details of teachers whose department is either Art or Science

(a) Create table Teacher in database school with the appropriate specification in order to
store the given data
b)

c)
d)

e)

f)

g)

h)
i)

j)

k)

l)

m)
n)

o)

You might also like