0% found this document useful (0 votes)
25 views35 pages

IP Practical File2

The document expresses gratitude to a teacher, family, and friends for their support in preparing a practical file. It includes an index and various SQL queries related to MySQL tables such as Sale, Inventory, Customer, and Employee, as well as Python programming tasks involving libraries like Pandas and data visualization with Matplotlib. Additionally, it lists resources for further learning and references used in the preparation of the document.

Uploaded by

pranavchawla101
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views35 pages

IP Practical File2

The document expresses gratitude to a teacher, family, and friends for their support in preparing a practical file. It includes an index and various SQL queries related to MySQL tables such as Sale, Inventory, Customer, and Employee, as well as Python programming tasks involving libraries like Pandas and data visualization with Matplotlib. Additionally, it lists resources for further learning and references used in the preparation of the document.

Uploaded by

pranavchawla101
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 35

Acknowledgement

I would like to express my heartfelt gratitude to my


teacher, Mrs. Heena, for providing me with this invaluable
opportunity to apply and practice the concepts I have
learned throughout this session in the preparation of this
Practical file. Her guidance, encouragement, and
dedication have been instrumental in enhancing my
understanding and application of the subject matter.

I would also like to extend my sincere thanks to my


brother, whose unwavering support and insights have
greatly contributed to my learning journey. Additionally, I
am deeply grateful to my friends for their valuable
guidance and collaborative spirit, which have helped me
grasp the concepts more effectively. Their encouragement
and assistance have played a significant role in the
successful completion of this file.
Index

01 – 07

03 – 04

05 - 07

09 – 13

14 – 23

24 – 26

27 – 29

30 – 32
MySQL

01
MySQL tables used in this Project for queries are:

Sale:

Inventory:

Customer:

Employee:

02
Single Row Functions / Scalar Functions
1. Add a new column commission to the Sale table with total length of 7 in which 2 decimal places should be there:

2. Calculate commission for sales agents as 12% of the sale price, insert the values to the newly added column
Commission and then display records of the table Sale where commission>73,000

3. Using table Sale, display InvoiceNo, SalePrice, and Commission such that Commission value is rounded off to 0.

03
4. In table INVENTORY, If the length of the car’s model is greater than 4 then fetch the substring starting from position
3 till the end from attribute Model.

5. Using the table EMPLOYEE, write SQL query to display employee name and the last 2 characters of his EmpId.

6. Using the table EMPLOYEE, write SQL query to display designation of employee and the position of character ‘e’ in
designation, if present.

7. Using the table EMPLOYEE, write SQL query to list the day of birth for all employees whose Salary > 25000.

04
Aggregate Functions / Multiple Row Functions
8. Using table SALE, find sum of Sale Price of the cars purchased by the customer having ID C0001.

9. Find the maximum and minimum commission from the SALE table.

10. List the total number of cars sold by each employee from Sale table.

11. List the maximum sale made by each employee from Sale table.

05
Group By in SQL
12. Display the number of cars purchased by each customer from the SALE table.

13. Display the customer Id and number of cars purchased if the customer purchased more than 1 car from SALE
table.

Cartesian Product
Tables:
Music Dance

14. From the all possible combinations of tuples of relations DANCE and MUSIC, display only those rows such that the
attribute name in both have the same value.

06
15. Display all possible combinations of tuples of relations DANCE and MUSIC.

Join / Natural join clause


16. Explicit use of JOIN clause.

17. Explicit use of NATURAL JOIN clause.

18. Explicit use of NATURAL JOIN clause.

07
08
Python Libraries
Installing libraries
19. Install Pandas library
11

1. Pandas
a) Series
20. Create a Series object using the python sequence with 5 elements:

21. Create a Series object 'vowel' to store all vowels individually. Its index should be 1,2,3,4 & 5.:

09
22. Create a series having names of any 5 famous monuments of India and assign their States as index
values.

23. Write the statement to get Qutub Minar and Hawa Mahal as output using positional index.

24. Considering the following code Find output of the code.


>>>import pandas as pd
>>>import numpy as np

>>>s2=pd.Series([12,np.nan,10])

>>>print(s2)

25. Create a Series object using ndarray that has 5 elements in the range 50 and 100:

10
26. Total no. of students to be admitted in Yoga school is 350 every year. Write code to create a series
object School that stores these total number of students for the year 2015 to 2022:

27. Create a Series object 'Item' that stores rate of each product as given below:
Soap 54
Salt 20
Sugar 39

>>>Write code to modify rate of Soap to 44 and Sugar to 42. print the changed rate:

11
28. No. of students in Class 11 and class 12 in three streams (science, commerce and humanities) are stored
in 2 series object.

29. Create a Series object 'population' to store population of 5 different metro cities and display the
population that are than 300000:

30. Create a series with numerical values from 1 to 10. Write script to:
a) Display 1st three values
b) Display last three values

12
31. Create a series 'temp' that stores temperature of seven days in it. Its index should be days of the week.

>>>Write script to:


a) Display all temp in reverse order

b) Display temp from Tuesday to Friday

c) Display square of all temperature

13
b) Dataframes
32. Create the following DataFrame 'Sport' containing sport wise marks for 5 students. Use 2D dictionary to
create DataFrame.

Solution:

Output:

33. Create a Datarame from list containing dictionaries of most economical bike with its name and rate of
three companies. Company name should be the row labels.

Solution:

Output:

14
34. a) Consider two series object staff and salaries that stores the number of people in various office
Departments and salaries distributed in these Departments respectively.
34. b) Write a program to create another Series object that stores average salary per Department and then
create a DataFrame object from these Series object
34. c) After creating DataFrame, rename all row labels with Department names.

Solution:

Output:

15
35. a) Create the following dataframe 'sales' containing year wise sales figure for five sales persons in INR.
Use the year as column labels, and sales person names as row labels.

35. b) Write a program to perform the following tasks:


i. Display row labels of 'sales’.
ii. Display column label of 'sales’.
iii. Display last two rows of the 'sales’.
iv. Display first two rows of the 'sales’.

Solution:

Output:

16
36. Create a DataFrame 'sales2' using dictionary as given below and write a program to append 'sales2' to
the DataFrame ‘Sales' created in previous practical 35.

Solution:

Output:

17
37. Create a dataframe 'cloth' as given below and write program to do followings:
 Check 'cloth' is empty or not
 Change 'cloth' such that it becomes its transpose
 Display no of rows and columns of 'cloth'
 Count and display Non NA values for each column
 Count and display Non NA values for each row

Solution:

18
Output:

38. For given DataFrame 'cloth' given in Practical 37, Write program to do followings:
 Change the name of 'Trouser' to 'pant' and Jeans to 'Denim'
 Increase price of all cloth by 10%
 Rename all the indexes to [C001, C002, C003, C004, COO5]
 Delete the data of C3 (C003) from the 'cloth'
 Delete size from 'cloth'

19
Solution:

20
Output:

21
39. Create a dataframe 'aid' as given below and write program to do following tasks:
 Display the books and shoes only
 Display toys only
 Display quantity in MP and CG for toys and books.
 Display quantity of books in AP

Solution:

22
Output:

23
2) Matplotlib
a) Histogram

40. Write a Python program to display a horizontal histogram for marks obtained out of 50, with a class
interval of 5.
Solution:

Output:

24
41. Write a Python program to display a histogram for marks obtained out of 50, with a class interval of 5.
The histogram should have specific edge colors and line width. Also, set the x-axis ticks to range from 0
to 50 with an interval of 5. Display the histogram.

Solution:

Output:

25
42. Write a Python program to display a bar-stacked histogram comparing the ages of boys and girls in
different age groups. Label the histogram appropriately and display it.
Solution:

Output:

26
b) Bar chart
43. Write a Python program to display a bar chart representing the number of IT students in different
classes. Add text annotations to the bars to show the number of students. Label the chart appropriately
and display it.

Solution:

Output:

27
44. Write a Python program to display a stacked bar chart comparing the number of IT and banking students
in different classes. Customize the appearance of the bars and display the chart with appropriate labels.

Solution:

Output:

28
45. Write a Python program to create a bar chart. The chart should show the number of IT and banking
students in different classes. Make sure to label the chart and include a key that explains what each bar
color represents.

Solution:

Output:

29
c) Line Plot
46. Write a Python program to create a line plot. The x-axis should represent the days of the week, and the
y-axis should represent some numerical values. Customize the grid lines to be red and dotted. Label the
axes appropriately and display the plot.

Solution:

Output:

30
47. Write a Python program to plot two datasets on a single graph. Use different styles and colors for each
dataset. Label the axes and add a key to explain what each line represents.

Solution:

Output:

31
48. Write a Python program to create two different line plots side by side in the same figure window. Use
the subplot() function to achieve this. Label the axes and add a key for each plot to explain what the
lines represent.

Solution:

Output:

32
Bibliography

❑ Informatics Practices NCERT Book

❑ https://www.learnpython4cbse.com

❑ https://learn.codesignal.com/

❑ https://copilot.microsoft.com/

❑ https://learn.codesignal.com/

❑ https://chat.openai.com/

❑ https://www.office.com

You might also like