Ip - Class Xii - Comprehensive Assignment Mid Term 2022-2023
Ip - Class Xii - Comprehensive Assignment Mid Term 2022-2023
PANDAS DATAFRAMES
I.
Considering the dataframe DF
BID BNAME TYPE
0 221 The Firm Thriller
1 312 Tangled Rom-com
Write the statement to carry out changes in the row indices to roman numerals for DF
dataframe and column names to BOOKNO, NAME and GENRE within the dataframe.
II. PROGRAMS
1.
States total_cases Total_deaths Total_recovered
Punjab 167 11 10
Delhi 1510 27 24
Andhra Pradesh 432 7 11
Haryana 185 3 29
Kerala 379 2 179
Maharashtra 2334 149 217
Madhya Pradesh 604 36 0
Tamil Nadu 1173 11 50
Considering a file covid.csv, Import the data from this file into a dataframe named ‘Covid’. Then
create a new dataframe which contains only those states’ data where the death count is more
than 10. Write the newly created dataframe in a text file by the name ‘HighToll.txt’. The file
should contain the row numbers from 1 to N and the column labels should be included.
2. Import data into a dataframe from Student.CSV file containing Student Rollno, Name, Stream,
Optional Subject. The program should display data of all students who have opted for a specific
optional subject. The subject should be accepted from the user. The name of the column is
‘OPT’
III. INDEXING
Answer the questions based on the following DataFrame – books
a)
BID BNAME TYPE
3 221 The Firm Thriller
5 312 Tangled Rom-com
6 123 Rainmaker Thriller
b) ‘Helen Fielding’
c)
BNAME BAUTHOR DOP
0 Digital Fortress Dan Brown 1999-12-12
1 Harry Potter J.K.Rowlings 2001-09-23
2 Informatics Practices Sumita Arora 2011-11-25
d)
BID BNAME BAUTHOR PRICE TYPE DOP
5 312 Tangled Emma Chase 375 Rom-com 2005-05-09
6 123 Rainmaker John Grisham 325 Thriller 2001-10-21
e)
BID 221
BNAME The Firm
BAUTHOR John Grisham
PRICE 250
TYPE Thriller
DOP 1995-01-01
f)
BNAME TYPE DOP
0 Digital fortress Thriller 1999-12-12
1 Harry Potter Children 2001-09-23
2 Informatics Practices TextBook 2011-11-25
3 The Firm Thriller 1995-01-01
4 Bridget Jones Diary Rom-com 2000-12-12
5 Tangled Rom-com 2005-05-09
6 Rainmaker Thriller 2001-10-21
2. Write the output of the given questions based on the following dataframe : friends
a) print(friends[[Name’,’Age’]])
b) print(friends.iloc[2:5,[1,3,4]])
c) print(friends.loc[1:2])
d) print(friends.iloc[1:2])
e) print(friends.loc[0:7:2])
f) print(friends.iloc[0:7:2])
g) print(friends.loc[7])
h) print(friends.iloc[2,[0,3,4]])
i) print(friends.loc[1:7:3, [‘Name’,’City’,’Email_id’]])
j) print(friends.Iloc[1:7:3, [0,2,4]])
k) print(friends.loc[6: , [‘Name’:’City’]])
l) print(friends[5])
PANDA SERIES
1. To create an empty series object the, the Series() function is used with _________________.
2. Missing data values in Panda Series are filled with a _______________ value.
3. Pandas word is derived from ____________________________.
4. The command to install pandas is ____________________________________.
5. __________________ function is used to display ‘n’ no. of rows from the end of the series.
6. The most commonly used pandas data structure is ______________________.
7. ______________________ is the collection of values and the operations that can be performed on them.
8. The size of Pandas series is ________________.
9. __________________ parameter is used to provide the data set values to the series.
10. ______________ attribute of series object is used to access the data in the series with the help of index
names.
11. ________________ attribute will return False if all the values in the series are missing.
12. ________________ is the process of performing an operation of each element of the series.
a) print(S*100)
b) print(S>0)
SQL FUNCTIONS
Consider a table Student with following attributes: - Sname, DOB, Gender, Class,
Section, Percentage
1. Display the details of all boys who were born in year 2006 or 2007.
2. Display the first four letters of the names of class XII students.
3. Display the details of the students who have string ‘Sa’ in their names.
4. Display the total number of characters in the names of the students.
5. Display a report for each student were born in the following format:
Reema Sharma was born on Wednesday in the month of January.
6. Display the location of the first occurrence of character ‘A’ in the names of the students.
7. Considering the value 20191.968, display it in the following format:
20100 , 20191.9, 20191.97
8. Display the average percentage of girls of section B and C separately born in year 2005
CLASS XI SYLLABUS
I. Write the SQL statement to create the following STUDENT table. (2)
Field name Data type Size Constraint
S_Name Varchar 20
S_rollno Int 5 Primary Key
Marks Decimal 5,2
Grade Char 1
II. Considering the following table ITEM, write SQL statements for the following: (18)
ITEM
ICODE INAME MATERIAL PRICE ORD_DATE GRADE QTY
A191 TROUSERS COTTON 1000 2016-01-21 A 45
A109 HALF SLEEVE SHIRT SILK 1150 2016-08-12 C 123
A107 T- SHIRT POLYESTER 800 2015-11-23 B 50
A198 FULL SLEEVE SHIRT COTTON 950 2016-10-09 C 55
A924 COAT WOOLLEN 4000 2017-01-01 A 15
A123 SCARF SILK 1200 2015-10-12 B 20
A342 JEANS DENIM NULL 2016-09-12 A 34
A987 JACKET NULL 2500 2017-01-09 B 45
1) Display the details of the items where the word shirt occurs in the item name.
2) Display the different types of material in the table.
3) Display the code, name and price of those items whose order date was in the month of
October, 2015.
4) Find the highest quantity for cotton material items.
5) Display a list of items that are of cotton, silk or polyester material.
6) Add a new row in the table. Assume data on your own
7) Find the total value of each item in the table according to the price and quantity.
8) Display the code, name and price of the items in descending order of price.
9) Display the total number of items having grade as ‘B’ and ‘C’
10) Display the average price of cotton material items.
11) Add a new row but with values only for icode, iname and price.
12) Increase the price of all items ordered in the month of October by 5%.
13) Remove the rows from the table where quantity is in the range of 20 to 40.
14) Display the details of items where price has not been entered.
15) Display the details of items that have N as the second last character in the item name.
16) Display the item name , price in descending order of price within ascending order of name.
17) Display the total number of grades given to items in the table.
18) Display double of the price with heading as “Double price” for all items in the table.
III. Write the output of the following SQL queries based on the ITEM table as given above.
(Consider only the data given in the table for outputs)
1) Select price from item where ord_date > ‘2017-01-01’ or grade = ‘B’;
2) Select distinct grade from item;
3) Select avg(price) from item;
4) Select count(distinct material) from Item;
5) Select icode, iname, grade from item where iname like ‘%s’;
6) Select Count(price), Count(*) from Item;
7) What is the cardinality and degree of item table as given above?
8) Select grade, price, iname from item order by grade, iname desc;
VI. Write the SQL commands on the basis of table ITEMS that has following table structure
Itemcode – int, Item_Name- Varchar, Item_desc - Varchar, Price – decimal, Qty – int
1. Write a Query to display maximum salary paid in each department in descending order of
maximum salary.
2. Write a Query to Display the Highest and Lowest salary of the employees.
3. Write a Query to Display the total salary of the employees with each manager number where
manager number is more than 7800.
4. Write a Query to Display the Sum, Average, Highest and Lowest salary of the employees who
were hired after 2000 in each job type.
5. Write a query to display the number of employees with same job but only for the jobs other
than President.
6. Write a query to display the Highest and lowest salary of each department whose maximum
salary is more than 3000.
7. Display the difference between highest and lowest salary of salesman and managers.
8. Display the Total Annual Salary paid to the employees but only for those employees whose
monthly salary is more than 1500 for department no. 10 and 20 separately.
9. Display the employee name, job type and commission earned for employees of department
number 10 and 20.
10. Display the total no. of employees hired in each year.
II. Study the following tables STAFF and answer the queries given below:
ID NAME DEPT POST EXPERIENCE GENDER
101 SIDHARTH SALES TRAINEE 12 M
104 RAGHAV FINANCE EXECUTIVE 5 M
107 NAMAN RESEARCH EXECUTIVE 3 M
114 NUPUR SALES MANAGER 9 F
109 JANVI FINANCE DIRECTOR 10 F
105 RAMA RESEARCH TRAINEE 3 F
117 JAMES SALES MANAGER 12 M
111 BINOY FINANCE EXECUTIVE 15 M
130 SAMUEL SALES DIRECTOR 10 M
1) Display the total no. of employees.
2) Find total no. of employees who have experience more than or equal to 10 employed at different
posts.
3) Display the lowest experience of employees in each department except finance.
4) Display the names of the staff members who are in sales department having more than 10 years of
experience.
5) Count the total number of male and female staff members.
6) Display the minimum allowance of female staff.
7) Display a list of all male staff members who are executives.
8) Display the list of members who are working in sales and research departments.
9) Display the list of directors with names starting with S.
10) Find the total number of staff members in each department.
11) Find the average experience of all the staff members in each department.
12) How many posts exist in the organization?
13) Write the output of the following:
i) SELECT DISTINCT POST FROM STAFF;
ii) SELECT COUNT(*) FROM STAFF WHERE GENDER = ‘F’;
iii) SELECT AVG(EXPERIENCE), POST FROM STAFF WHERE ID >105 GROUP BY POST
HAVING POST IN (‘MANAGER’, ‘DIRECTOR’) ORDER BY AVG(EXPERIENCE) DESC;
iv) SELECT COUNT(*), GENDER FROM STAFF WHERE POST NOT IN (‘MANAGER’, ‘TRAINEE’)
GROUP BY GENDER;
DATA VISUALIZATION
1. Using Python Matplotlib which graph is used to count how many values fall into each interval.
2. Which chart is best suited to represent categorical data?
3. Considering the given code, which of the following statements would display the given chart?
a = [1,2,3,4,5,6]
VI = [23,45,12,26,29,20]
VII = [21,34,22,34,19,27]