IP Practical File2
IP Practical File2
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.
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.
>>>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.
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.
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
❑ https://www.learnpython4cbse.com
❑ https://learn.codesignal.com/
❑ https://copilot.microsoft.com/
❑ https://learn.codesignal.com/
❑ https://chat.openai.com/
❑ https://www.office.com