Colored Part 2
Colored Part 2
19. Creating a python program for plotting a multiple bar chart from a CSV file. 25
SQL Queries
21. SQL COMMANDS EXERCISE – 1 (Basic Queries – I) 27
22. SQL COMMANDS EXERCISE – 2 (Basic Queries – II) 29
23. SQL COMMANDS EXERCISE – 3 (Aggregate functions, Order by Group by, 31
Having Clause)
24. SQL COMMANDS EXERCISE – 4 (Math Functions) 33
25. SQL COMMANDS EXERCISE – 5 (Text Functions) 35
26. SQL COMMANDS EXERCISE – 6 (Date Functions) 37
2
EX.NO: 1
DATE:
CREATING A PYTHON PROGRAM TO CREATE A
SERIES USING A DICTIONARY.
Q1:
Answer :
RESULT:
Thus, the above Python program has been executed successfully, and the output has
been verified.
SAMPLE OUTPUT:
************************************************************************************************
3
EX.NO: 2
DATE:
CREATING A PYTHON PROGRAM TO CREATE A
SERIES USING SCALAR VALUE
Q2:
To write a Python program to create a Series object that stores the Initial budget
allocated (50000/- each) for the four quarters of the year: Qtr1, Qtr2, Qtr3 and Qtr4.
Answer:
RESULT:
Thus, the above Python program has been executed successfully, and the output has
been verified.
Sample Output:
4
EX.NO: 3
DATE:
CREATING A PYTHON PROGRAM TO CREATE A
SERIES USING NUMPY ARRAY
Q3:
To write a Python program to create a Series object that stores the Employee names
as index and their Salary as values
Answer:
RESULT:
Thus, the above Python program has been executed successfully, and the output has
been verified.
Sample Output:
*************************************************************************************************
5
EX.NO: 4
DATE:
To Write a Python program to create a Series object with Employee names as the index
and their salaries as values. Accept the name of the employee whose salary needs to be
changed, along with the new salary, and update it in the Series.
Answer:
RESULT:
Thus, the above Python program has been executed successfully, and the output has
been verified.
Sample Output:
****************************************************************************************
6
EX.NO: 5
DATE:
Answer:
RESULT:
Thus, the above Python program has been executed successfully, and the output has
been verified.
Sample Output:
**************************************************************************************************
7
EX.NO: 6
DATE:
To write a Python program to create two series i.e. population and average
income of Four Zones, and then calculate per capita income storing in third
pandas series print it.
Answer:
RESULT:
Thus, the above Python program has been executed successfully, and the output has
been verified.
Sample Output:
***************************************************************************************
8
EX.NO: 7
DATE:
To write a Python program to create a Series using list and display the following
attributes of the Series: (i) index (ii) dtype (iii) size (iv) shape (v) hasnans
Answer:
RESULT:
Thus, the above Python program has been executed successfully, and the output has
been verified.
SAMPLE OUTPUT:
*************************************************************************************************
9
EX.NO: 8
DATE:
To write a Python program to create a Series using list of Marks of 10 students and
display first 5 Students’ marks and Last 2 Students’ marks from Series object.
Answer:
RESULT:
Thus, the above Python program has been executed successfully, and the output has
been verified.
SAMPLE OUTPUT:
**************************************************************************************************
10
EX.NO: 9
DATE:
To write a Python program to create a panda’s Data Frame for the following table Using
Nested list:
Answer:
RESULT:
Thus, the above Python program has been executed successfully, and the output has
been verified.
SAMPLE OUTPUT:
**************************************************************************************************
11
EX.NO: 10
DATE:
To write a Python program to create a panda’s DataFrame called DF for the following
table Using Dictionary of List and perform the following operations:
Answer:
RESULT:
Thus, the above Python program has been executed successfully, and the output has
been verified.
12
SAMPLE OUTPUT:
*************************************************************************************************
13
EX.NO: 11
DATE:
Q11:
To write a Python program to create a panda’s DataFrame called DF for the following
table Using Dictionary of List and perform the following operations:
(i) Insert a new column “Bags” with values as [5891, 8628, 9785, 4475].
Answer:
RESULT:
Thus, the above Python program has been executed successfully, and the output has
been verified.
14
SAMPLE OUTPUT:
**************************************************************************************************
15
EX.NO: 12
DATE:
RESULT:
Thus, the above Python program has been executed successfully, and the output has
been verified.
16
Sample Output:
*************************************************************************************
17
EX.NO: 13
DATE:
To write a Python program to create a panda’s DataFrame called DF for the following table
using Dictionary of List and display the details of students whose Percentage is more than
85.
Answer:
RESULT:
Thus, the above Python program has been executed successfully, and the output has
been verified.
SAMPLE OUTPUT:
*******************************************************************************************
18
EX.NO: 14
DATE:
To write a Python program to create a DataFrame using Dictionary of list and display
the following attributes of the DataFrame: (i) index (ii) columns (iii) axes (iv) dtypes
(v) shape (vi) dimension (vii) T
Answer:
RESULT:
Thus, the above Python program is executed successfully and the output is verified.
SAMPLE OUTPUT:
*******************************************************************************************
19
EX.NO: 15
DATE:
To write a Python program to create a panda’s DataFrame called Students for the
following table and demonstrate iterrows and iteritems.
Answer:
RESULT:
Thus, the above Python program has been executed successfully, and the output has
been verified.
20
SAMPLE OUTPUT:
**********************************************************************************************
21
EX.NO: 16
DATE:
To Write a Python program to store the details of Employess’ such as Empno, Name,
Salary into a Employee.csv file. Also, write a code to read employee details from csv
file.
Answer:
RESULT:
Thus, the above Python program has been executed successfully, and the output has
been verified.
SAMPLE OUTPUT:
**********************************************************************************************
22
Ex.No: 21
DATE:
SQL COMMANDS EXERCISE – 1
(Basic Queries – I)
Q21:
To write Queries for the following Questions based on the given table:
USE EMPS;
27
(e) Write a Query to List all the tables that exists in the current database.
SHOW TABLES;
Output:
(f) Write a Query to insert all the rows of above table into Info table.
(g) Write a Query to display all the details of the Employees from the above table 'INFO'.
Output:
****************************************************************************************************
28
Ex.No: 22
DATE:
SQL COMMANDS EXERCISE – 2
(Basic Queries – II)
Q23
To write Queries for the following Questions based on the given table:
(a) Write a Query to Display Employees’ name and City from the above table.
Output:
(b) Write a Query to Display all details of Employees who are living in Chennai.
Output:
29
(c) Write a Query to get the name and salary of the employee whose salary is above
15000 and gender is not male.
(d) Write a query to update increase 10% Salary of an employee whose City is 'CHENNAI'
and Gender is 'MALE'.
*************************************************************************
30
Ex.No: 23
DATE:
SQL COMMANDS EXERCISE – 3
(Aggregate Functions, Order By Group By, Havning Clause)
Q24:
To write Queries for the following Questions based on the given table:
Output:
Output:
(c) Write a Query to display maximum salary and minimum salary of employees.
SELECT MAX(SALARY), MIN(SALARY) FROM INFO;
Output:
31
(d) Write a Query to count the number of employees earning more than 25000.
(e) Write a query to display sum of salary of the employees grouped by department wise.
(f) Write a query to display the department names where number of employees are
greater than or equal to 2.
Output:
****************************************************************************************
32
Ex.No: 24
DATE:
SQL COMMANDS EXERCISE – 4
(Mathematical Functions)
Q25:
To write Queries for the following Questions based on the given table -"STU":
(a) Write a Query to Display square of age that got admission in the month of August.
Output:
33
(c) Write a Query to display Student names and their Percentage in round figure.
Output:
(d) Display Name, Percentage and round up the remainder marks up to 2 decimal
places.
Output:
**************************************************************************************
34
Ex.No: 25
DATE:
SQL COMMANDS EXERCISE – 5
(Text Functions)
Q26:
To write Queries for the following Questions based on the given table -"STU":
Output:
(b) Write a Query to display department name and its respective number of characters
in Dept column.
35
(c) Write a Query to display first 2 characters of the column Name.
Output:
(e) Write a query to display the names of all students and extract five characters from the
third position of the 'Name' field.
Output:
**********************************************************************************************
36
Ex.No: 26
DATE:
SQL COMMANDS EXERCISE – 6 (Date Functions)
Q27:
To write Queries for the following Questions based on the given table:
(a) Write a Query to display student name and month of date of admission of all
students.
(b) Write a Query to display Student name and day name of the students’ DOA of the
table STU.
37
(c) Write a query to display the joining year of IP students.
SELECT YEAR(DOA) FROM STU WHERE DEPT='IP'
Output:
(d) Write a Query to Display the month for the date_of_birth of all students.
Output:
(e) Write a query to display the names of the students who joined in the month of June.
*********************************************************************************************
38