INFORMATICS PRACTICES
PRACTICAL FILE
Name : Debshri Chatterjee
Class : XII – F
Roll No. : 21661058
Q1. Write a program to generate a series of float numbers from 41.0 to 60.0
with an increment of 2.5 each.
Sol.
Output
Q2. Write a program to generate a series of 10 numbers with a scalar value
of 44.
Sol.
Output
Q3. Create a panda’s series from a dictionary of values and a ndarray.
Sol.
Output
Q4. Given a Series, print all the elements that are above the 75th percentile.
Sol.
Output
Q5. Create a dataframe and iterate them over rows.
Sol.
Output
Q6. Create a data frame for examination results and display row labels,
column labels datatypes of each column and the dimensions.
Sol.
Output
Q7. Create the following DataFrame Sales containing year wise sales figures
for five salespersons in INR. Use the years as column labels, and
salesperson names as row labels.
2018 2019 2020 2021
Kapil 110 205 177 189
Kamini 130 165 175 190
Shikhar 115 206 157 179
Mohini 118 198 183 169
1. Create the DataFrame.
Sol.
Output
2. Display the row labels of Sales.
Sol.
Output
3. Display the column labels of Sales.
Sol.
Output
4. Display the data types of each column of Sales.
Sol.
Output
5. Display the dimensions, shape, size and values of Sales.
Sol.
Output
Q8. Consider above dataframe and write code to do the following:
1. Display the last two rows of Sales.
Sol.
Output
2. Display the first two columns of Sales.
Sol.
Output
Q10. Use above dataframe and do the following:
1. Change the DataFrame Sales such that it becomes its transpose.
Sol.
Output
2. Display the sales made by all sales persons in the year 2018.
Sol.
Output
3. Display the sales made by Kapil and Mohini in the year 2019 and 2020.
Sol.
Output
4. Add data to Sales for salesman Nirali where the sales made are [221, 178,
165, 177, 210] in the years (2018, 2019, 2020, 2021] respectively.
Sol.
Output
5. Delete the data for the year 2018 from the DataFrame Sales.
Sol.
Output
6. Delete the data for sales man Shikhar from the DataFrame Sales.
Sol.
Output
7. Change the name of the salesperson Kamini to Rani and Kapil to Anil.
Sol.
Output
8. Update the sale made by Mohini in 118 to 150 in 2018.
Sol.
Output
Q11. Write a Pandas program to compare the elements of the two Pandas Series.
Sol.
Output
Q12. Write a Pandas program to sort a given Series
Sol.
Output
13. Create a dataframe and reindex its rows using reindex().
Sol.
Output
14. Write a Pandas program to convert the first column of a DataFrame as a
Series.
Sol.
Output
Q15. Write a Pandas program to add some data to an existing Series.
Sol.
Output
Q16. Plot the following data on a line chart and customize the chart
according to the below given instructions:
Month January February March April May
Sales 520 350 475 580 600
Monthly Sales Report
1. Write a title for the chart “The Monthly Sales Report”
2. Write the appropriate titles for both the axes
3. Write code to display legends
4. Display blue color for the line
5. Use the line style – dashed
6. Display diamond style markers on data points
Sol.
Output
Q17. Pratyush Garments has recorded the following data into their register
for their income from cotton clothes and jeans. Plot them on the line
chart.
Day Monday Tuesday Wednesday Thursday Friday
Cotton 450 560 400 605 580
Jeans 490 600 425 610 625
Apply following customization to the line chart.
1. Write a title for the chart “The Weekly Garment Orders”
2. Write the appropriate titles of both the axes
3. Write code to Display legends
4. Display your choice of colors for both the lines cotton and jeans
5. Use the line style – dotted for cotton and dashdot for jeans
6. Display plus markers on cotton and x markers on jeans
Sol.
Output
Q18. Observe the given data for monthly views of one of the youtube
channels for 6 months. Plot them on the line chart.
Month January February March April May June
Views 2500 2100 1700 3500 3000 3800
Apply the following customization to the chart.
1. Give the title for the chart – “YouTube Stats”
2. Use the “Month” label for X-Axis and “Views” for Y-Axis
3. Display legends
4. Use dashed lines with the width 5 point
5. Use red color for the line
6. Use dot marker with blue edge color and black fill color
Sol.
Output
Q19. Observe the following data and plot data according to the given
instructions:
Batsman 2017 2018 2019 2020
Virat Kohli 2501 1855 2203 1223
Steve Smith 2340 2250 2003 1153
Babar Azam 1750 2147 1896 1008
Rohit Sharma 1463 1985 1854 1638
Kane Williamson 1256 1785 1874 1974
Jos Buttler 1125 1853 1769 1436
1. Create a bar chart to display data of Virat Kohli and Rohit Sharma
Sol.
Output
2. Create a bar chart to display data of Steve Smith, Kane Williamson and
Jos Buttler. Customize chart as per your wish.
Sol.
Output
3. Display data of all players for the specific year.
Sol.
Output
Q20. Write SQL commands for (a) to (j) and write output for (k) to (n) on
the basis of Teacher relation given below:
No Name Age Department Date_of_join Salary Sex
1 Jugal 34 Computer 10/01/97 12000 M
2 Sharmila 31 History 24/03/98 20000 F
3 Sandeep 32 Maths 12/12/96 30000 M
4 Sangeeta 35 History 01/07/99 40000 F
5 Rakesh 42 Maths 05/09/97 25000 M
6 Shyam 50 History 27/06/98 30000 M
7 Shivom 44 Computer 25/02/97 21000 M
Sol. Code to create table:
Output
(a) To show all information about the teacher of history department
Sol.
Output
(b) To list the names of all teachers with their date of joining in
ascending order.
Sol.
Output
(c) To display Teacher’s name, salary, age for male teachers only.
Sol.
Output
(d) To count the number of teachers with Age>23.
Sol.
Output
(e) To insert a new row in the teacher table with the following data:
8, “Vijay”, 26, “Computer”,{13/05/95}, 35000, “M”
Sol.
Output
(f) To show all information about the teachers in this table.
Sol.
Output
(g) To list the name of female teachers who are in history
department.
Sol.
Output
(h) Add a new column named “Address”.
Sol.
Output
(i) Display table in the alphabetical order to name.
Sol.
Output
(j) Display the Age of the teachers whose name starts with ‘S’.
Sol.
Output
(k) Select count(distinct Department) from Teachers;
Sol.
Output
(l) Select AVG(Salary) from Teachers where Date_of_join<’12/07/96’;
Sol.
Output
(m) Select SUM(Salary) from Teachers where Date_of_join<’12/07/96’;
Sol.
Output
(n) Select MAX(Age) from Teachers where Sex=’F’;
Sol.
Output