XII IP Lab Manual - 2022 - 23

You might also like

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

Informatics and Practices (065) Lab Manual – 2022-23

1) Write a python to create a panda’s series from a dictionary of values and a ndarray
ANS:

OUPUT

1
Informatics and Practices (065) Lab Manual – 2022-23

2. Create a data frame for examination result and display row labels, column labels data types of each column
and
the dimensions
ANS:

OUTPUT

3. Write a python program to convert third column of a DataFrame as Series object.


ANS

OUTPUT

2
Informatics and Practices (065) Lab Manual – 2022-23

4. Write a python program to find marks of all the students greater than 57 and also display whose marks are in
between 70 and 80.
ANS:

OUTPUT

3
Informatics and Practices (065) Lab Manual – 2022-23

5. Write a menu driven python program to perform the following operation on a Series object
 Slicing of Series object without step
 Slicing of Series object with step
 Exit
Ans:

4
Informatics and Practices (065) Lab Manual – 2022-23

OUTPUT

5
Informatics and Practices (065) Lab Manual – 2022-23

6
Informatics and Practices (065) Lab Manual – 2022-23

6. Write a python program to create a line chart from the following sales.csv file. Consider month_number of
X-axis and ‘total_profit’ on Y-axis

Ans:

OUTPUT

7
Informatics and Practices (065) Lab Manual – 2022-23

7. Write a python program to create a bar chart from the following sales.csv file. In bar graph, represent
facecream and facewash sales in every month.
Note: Consider the same sales.csv file which is given in QNo. 6
Ans:

OUTPUT

8
Informatics and Practices (065) Lab Manual – 2022-23

8. Write a python program to create a line chart from the following sales.csv file. Each product sales should
come on Y-axis and month name should come on X-axis with different markers.
Note: Consider the same sales.csv file which is given in QNo. 6
Ans:

OUTPUT

9
Informatics and Practices (065) Lab Manual – 2022-23

9. Write a python program to create a histogram from the following sales.csv file. Consider range of
‘total_income’ X-axis and that range count on Y-axis
Ans:

OUTPUT

10
Informatics and Practices (065) Lab Manual – 2022-23

10. Write a Pandas program to create a Series object and then display the Series object elements
which are exactly divisible by 5.
Ans:

OUTPUT

11
Informatics and Practices (065) Lab Manual – 2022-23

11. Write a Pandas program to add, subtract, multiple and divide two Pandas Series.
ANS:

OUTPUT

12
Informatics and Practices (065) Lab Manual – 2022-23

12. Write a Python Program to create the DataFrame with following values and perform attributes
of DataFrame on it.
Name Rno Marks Addr
Ram 1 56.78 Bangalore
Keshav 2 62.12 Mangalore
Riya 3 77.89 Chikmagalur
Madhav 4 88.09 Mysore
Zara 5 99.00 Hubli
Chandhan 6 98.00 Coorg

ANS:

OUTPUT

13
Informatics and Practices (065) Lab Manual – 2022-23

13. Write a Python Program to create the following DataFrame and perform Boolean
Indexing on it.

ANS:

OUTPUT

14
Informatics and Practices (065) Lab Manual – 2022-23

14. Write a Python Program to create the following DataFrame and selecting rows/column using loc
and iloc function.

ANS:

OUTPUT:

15
Informatics and Practices (065) Lab Manual – 2022-23

15. Write a Python Program to create the following DataFrame and replace all negative numbers with
zero(0).

Ans:

OUTPUT

16
Informatics and Practices (065) Lab Manual – 2022-23

16. Write a Python Program to create a DataFrame using dictionary of Series, dictionary and CSV
files.

OUTPUT:

17
Informatics and Practices (065) Lab Manual – 2022-23

18
Informatics and Practices (065) Lab Manual – 2022-23

17. A python program to create a DataFrame from CSV file and perform iterrows() and iteritems() methods
on DataFrame.
Ans:

19
Informatics and Practices (065) Lab Manual – 2022-23

OUTPUT

20
Informatics and Practices (065) Lab Manual – 2022-23

18. A python program to create a DataFrame from CSV file and perform head() and tail() operations on
DataFrame.
Ans:

OUTPUT

21
Informatics and Practices (065) Lab Manual – 2022-23

19. Write a Python Program to create a Series object using arrange() method and perform
attributes of Series on it.
Ans:

OUTPUT

22
Informatics and Practices (065) Lab Manual – 2022-23

23
Informatics and Practices (065) Lab Manual – 2022-23

SQL
20) Consider the following table and write SQL commands for all the questions

i. Create a new database in the name of “practicals”


Ans

ii. To select the database called “practicals”


Ans

iii. To create above table


Ans

iv. List all the tables that exists in the current database
Ans

24
Informatics and Practices (065) Lab Manual – 2022-23

v. Display the description of the table


Ans

vi. Insert all the rows


Ans

vii. Display only type of the garments


Ans

25
Informatics and Practices (065) Lab Manual – 2022-23

viii. Display only type of the garments


And rename the column name as ‘garment type’ in output
Ans

ix. Display only type of the garments ends with skirt


Ans

x. Display only type of the garments starts with pencil


Ans

xi. Display the garment names whose price is in between 900 to 1200
Ans

(or)

26
Informatics and Practices (065) Lab Manual – 2022-23

xii. Display the garment names whose available quantity is more than 20
Ans

xiii. Display the garment names whose available quantity is 20 or more


Ans

xiv. Display the garment type based on ascending order of their names
Ans

(or)

27
Informatics and Practices (065) Lab Manual – 2022-23

xv. Display garment codes based on descending order of their names.


Ans

xvi. Display the garment type based on descending order of their price.
Ans

xvii. Display the garment code whose name doesn’t starts with pant
Ans

xviii. Display all the garment codes and their names except whose prices is in between 800 and
1200
Ans

28
Informatics and Practices (065) Lab Manual – 2022-23

xix. Increase all garment price by 10%


Ans

(or)

xx. Add a new column called ‘brand’ which will accept the values as strings.
Ans

xxi. Delete ‘brand’ column


Ans

xxii. Change the garment type to “bell bottom” whose garment code is “10045”
Ans

xxiii. Delete all the details of garment whose gcode is 12345


Ans

xxiv. Change the readydate value to NULL whose gcode is 10012


Ans

xxv. Display the garment details whose readydate is not given.


Ans

29
Informatics and Practices (065) Lab Manual – 2022-23

21) Consider the following empl table and write SQL commands for the following questions from (i) to
(xxxii).

i) Create above table.


Ans: create table empl(empno int primary key, ename varchar(20), job varchar(20),mgr int,hiredate date,sal
decimal(6,2), comm decimal(6,2), deptno int);
ii) Insert all the rows.
insert into empl values(8369,'smith','clerk',8902,'1990-12-18',800,null,20);
insert into empl values(8499,'ANYA','SALESMAN',8698,'1991-02-20',1600,300,30);
insert into empl values(8521,'SETH','SALESMAN',8698,'1991-02-22',1250,500,30);
insert into empl values(8566,'MAHADEVAN','MANAGER',8839,'1991-04-02',2985,NULL,20);
insert into empl values(8654,'MOMIN','SALESMAN',8696,'1991-09-28',1250,1400,30);
insert into empl values(8698,'BINA','MANAGER',8839,'1991-05-01',2850,NULL,30);
insert into empl values(8839,'AMIR','PRESIDENT',NULL,'1991-11-18',5000,NULL,10);
insert into empl values(8844,'KULDEEP','SALESMAN',8698,'1991-09-08',1500,0,30);
insert into empl values(8882,'SHIVANSH','MANAGER',8839,'1991-06-09',2450,NULL,10);
insert into empl values(8886,'ANOOP','CLERK',8888,'1993-01-12',1100,NULL,20);
insert into empl values(8888,'SCOTT','ANALYST',8566,'1992-12-09',3000,NULL,20);
insert into empl values(8900,'JATIN','CLERK',8698,'1991-12-03',950,NULL,30);
insert into empl values(8902,'FAKIR','ANALYST',8566,'1991-12-03',3000,NULL,20);
insert into empl values(8934,'MITA','CLERK',8882,'1992-01-23',1300,NULL,10);

30
Informatics and Practices (065) Lab Manual – 2022-23

iii) Display all details of all employees.


Ans: select * from empl;

iv) Display all the employees minimum, maximum and average salaries
Ans:

v) Display all the employees minimum, maximum and average commission


Ans:

vi) Display average salary of all employees who are working in deptno 20.
Ans:

31
Informatics and Practices (065) Lab Manual – 2022-23

vii) Display the total number of employees who are working for department number 10.
Ans:

viii) Write a SQL command to display total employees in each job.


Ans:

ix) Write a SQL command to display total salary for each department along with dept no.
Ans:

x) Write a SQL command to display number of employees in each department along with
dept no.
Ans:

32
Informatics and Practices (065) Lab Manual – 2022-23

xi) Write a SQL command to display average salary of employees in each job type.
Ans:

xii) Write a SQL command to display HIGHEST, LOWEST salary of employees in each job type.
Ans:

xiii) Write a SQL command to display employee name and their job in the increasing order of their salary.
Ans:

33
Informatics and Practices (065) Lab Manual – 2022-23

xiv) Display the name of departments. Each department should be displayed once.
Ans:

xv) Display the count of number departments without duplicate values.


Ans:

xvi) Display name of employee in lower case and upper case


Ans:

34
Informatics and Practices (065) Lab Manual – 2022-23

xvii) Display the position of the string ‘LE’ in field job of table EMPL.
Ans:

xviii) Display the jobs where the number of employee is less than 3.
Ans:

xix) Find the total number of Employee from empl table.


Ans:

35
Informatics and Practices (065) Lab Manual – 2022-23

xx) Display first three letters in every employee name


Ans:

xxi) Display last three letters in every employee name


Ans:

36
Informatics and Practices (065) Lab Manual – 2022-23

xxii) Display number of characters in every employee name


Ans:

xxiii) Display employee name by trimming left side and right side spaces
Ans;

37
Informatics and Practices (065) Lab Manual – 2022-23

xxiv) Display employee name and year of join


Ans:

xxv) Display employee name and month of join (month should be in decimals)
Ans:

38
Informatics and Practices (065) Lab Manual – 2022-23

xxvi) Display employee name and month name of their hiredate


Ans:

xxvii) Display employee name and day name of their hiredate


Ans:

xxviii) Display employee name who is taking highest salary.


Ans:

39
Informatics and Practices (065) Lab Manual – 2022-23

xxix) Display employee name and their job who joined in the year of 1993.
Ans:

xxx) Display employee name and their job who joined in the month of ‘January’.
Ans:

xxxi) Display employee name and their job who joined in the month of ‘01’.
Ans:

xxxii) Display employee name and their job who joined on ‘Tuesday’.
Ans:

40

You might also like