0% found this document useful (0 votes)
108 views31 pages

Certificate: Central Board of Secondary Education

Here are some common SQL commands: SELECT - Used to select data from a database table INSERT INTO - Used to insert new records in a table UPDATE - Used to update existing records in a table DELETE - Used to delete records from a table WHERE - Used to filter records LIMIT - Used to specify the number of records to return ORDER BY - Used to sort the records in ascending or descending order GROUP BY - Used to group records by one or more columns HAVING - Used with GROUP BY to filter groups INNER JOIN - Used to combine columns from two or more tables

Uploaded by

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

Certificate: Central Board of Secondary Education

Here are some common SQL commands: SELECT - Used to select data from a database table INSERT INTO - Used to insert new records in a table UPDATE - Used to update existing records in a table DELETE - Used to delete records from a table WHERE - Used to filter records LIMIT - Used to specify the number of records to return ORDER BY - Used to sort the records in ascending or descending order GROUP BY - Used to group records by one or more columns HAVING - Used with GROUP BY to filter groups INNER JOIN - Used to combine columns from two or more tables

Uploaded by

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

Certificate

This is to certify that the work entitled is


performed by Divyansh Gupta
(Roll No. ) under the guidance and
supervision.
To the of my knowledge and relief the project
here in embodies the work of the candidate
himself and has duly been completed. The
project fulfills the requirement of ordinance
related to the
Central Board of Secondary Education
and is up to mark, both in respect to the
content and language for being referred to the
examiner.

Principal: Teacher:
Mrs. Shalini Prajapati Mr. Alok Kanchan
Acknowledgement

It gives me great pleasure to express my


gratitude towards our C.Sc. teacher
Mr. Alok Kanchan for his guidance, support
and management throughout the duration of
the project. Without his motivation and help,
the successful completion of this project
would not have been possible.

I am extremely thankful to our principal


Mrs. Shalini Prajapati for extending her
support.

I would also thank my institution and faculty


members without whom this project would
have been a distant reality. I also extend my
heartful thanks to my family and well-wishers.
ABOUT SCHOOL

FERTILIZER PUBLIC SCHOOL is the


outcome of the unflinching determination &
efforts of some enlightened mind of
SHAHJAHANPUR,
Which revitalize the Indian system of
education.

The fundamental object of this school is to


provide a comprehensive system of learning
to stimulate the intellectual, physical &
spiritual facilities of the students.

Emphasize on academic excellence through


concept of group studies , time management
are some of the management.

This aims to equip the students to accomplish


rare synthesis of intellectualism & spiritualism.
About PYTHON

Python is an interpreted, high-level, general-


purpose programming language. Created
by Guido van Rossum and first released in
1991, Python's design philosophy
emphasizes code readability with its notable
use of significant whitespace. Its language
constructs and object-oriented approach aim
to help programmers write clear, logical code
for small and large-scale projects.

Python is dynamically typed and garbage-


collected. It supports multiple programming
paradigms, including procedural, object-
oriented, and functional programming. Python
is often described as a "batteries included"
language due to its comprehensive standard
library.
WAP to Print Fibonacci Series
n1 = 0
n2 = 1
count = 0
if nterms <= 0:
print("Please enter a positive integer")
elif nterms == 1:
print("Fibonacci sequence upto",nterms,":")
print(n1)
else:
print("Fibonacci sequence upto",nterms,":")
while count < nterms:
print(n1,end=' , ')
nth = n1 + n2
# update values
n1 = n2
n2 = nth

count += 1 Output
WAP to Print Sum of n Natural Numbers

num = 16
if num < 0:
print("Enter a positive number")
else:
sum = 0
# use while loop to iterate un till zero
while(num > 0):
sum += num
num -= 1
print("The sum is",sum)

Output
WAP to Check No. is Odd or Even

num = int(input("Enter a number: "))


if (num % 2) == 0:
print("{0} is Even".format(num))
else:
print("{0} is Odd".format(num))

Output
WAP to Find the Area of Triangle

a=5
b=6
c=7
area = (s*(s-a)*(s-b)*(s-c)) ** 0.5
print('The area of the triangle is:’,area)

Output
WAP to Check Whether No. is Positive,
Negative or 0

num = float(input("Enter a number: "))


if num >= 0:
if num == 0:
print("Zero")
else:
print("Positive number")
else:
print("Negative number")

Output
WAP to Check Whether Input No. is Prime or
Not

num = 407
if num > 1:
for i in range(2,num):
if (num % i) == 0:
print(num,"is not a prime number")
print(i,"times",num//i,"is",num)
break
else:
print(num,"is a prime number")
else:
print(num,"is not a prime number")
Output
WAP to Find The Largest among Three Input
Numbers

num1 = 10
num2 = 14
num3 = 1
if (num1 >= num2) and (num1 >= num3):
largest = num1
elif (num2 >= num1) and (num2 >= num3):
largest = num2
else:
largest = num3
print("The largest number between" ,num1," ,",num2,
"and",num3,"is",largest)

Output
WAP to Check the Input year is a Leap Year or
Not
year = 2000
if (year % 4) == 0:
if (year % 100) == 0:
if (year % 400) == 0:
print("{0} is a leap year".format(year))
else:
print("{0} is not a leap year".format(year))
else:
print("{0} is a leap year".format(year))
else:
print("{0} is not a leap year".format(year))

Output
WAP to Swap Two Variables

x=5
y = 10
temp = x
x=y
y = temp
print('The value of x after swapping: {}'.format(x))
print('The value of y after swapping: {}'.format(y))

Output
WAP to Find Factorial of a No.

num = 7
factorial = 1
if num < 0:
print("Sorry, factorial does not exist for negative
numbers")
elif num == 0:
print("The factorial of 0 is 1")
else:
for i in range(1,num + 1):
factorial = factorial*i
print("The factorial of",num,"is",factorial)

Output
WAP to Check No. is Palindrome Or Not

n=int(input("Enter number:"))
temp=n
rev=0
while(n>0):
dig=n%10
rev=rev*10+dig
n=n//10
if(temp==rev):
print("The number is a palindrome!")
else:
print("The number isn't a palindrome!")

Output
WAP to find Volume And Surface Area Of
Cuboid

length = float(input('Please Enter the Length of a Cuboid: '))


width = float(input('Please Enter the Width of a Cuboid: '))
height = float(input('Please Enter the Height of a Cuboid: '))

SA = 2 * (length * width + length * height + width * height)

Volume = length * width * height

LSA = 2 * height * (length + width)

print("\n The Surface Area of a Cuboid = %.2f " %SA)


print(" The Volume of a Cuboid = %.2f" %Volume);
print(" The Lateral Surface Area of a Cuboid = %.2f " %LSA)

Output
WAP to get Details of Students In Class

Count=int(input(“How many students are there in


the class?”))
Fileout=open(“marks.det”,’r’)
For i in range(count):
Print(“Enter Details For Student”,(i+1),”below:”)
Rollno=int(input(“Roll No.:”))
Name=input(“Name:”)
Marks=float(input(“Marks:”))
Rec=str(Rollno)+”,”+Name+”,”+str(Marks)+”\n”
Fileout.write(rec)
Fileout.close()
Output
WAP to Print Sum Of Squares Of n Natural
Nos.

n=int(input(“Enter No.”))
def sum():
if n==1:
return 1
else:
n**2 + sum(n-1)
sum(n)
Output
WAP to Create Multiple Line Chart on a
Common Plot

import numpy as np
import matplotlib.pyplot as plt

Data=[[5,25,45,20],[8,13,29,27],[9,29,27,39]]
X=np.range(4)
plt.plot(X, Data[0],color=’b’,label=’range1’)
plt.plot(X, Data[1],color=’g’,label=’range2’)
plt.plot(X, Data[2],color=’r’,label=’range3’)
plt.legend(loc=’upper left’)
plt.title(“Multirange Line Chart”)
plt.xlabel(‘X’)
plt.ylabel(‘Y’)
plt.show()
Output
WAP to Create Multiple Line Chart on a
Common Plot

import numpy as np
import matplotlib.pyplot as plt

Data=[[5,25,45,20],[8,13,29,27],[9,29,27,39]]
X=np.range(4)
plt.plot(X, Data[0],color=’b’,label=’range1’)
plt.plot(X, Data[1],color=’g’,label=’range2’)
plt.plot(X, Data[2],color=’r’,label=’range3’)
plt.legend(loc=’upper left’)
plt.title(“Multirange Line Chart”)
plt.xlabel(‘X’)
plt.ylabel(‘Y’)
plt.show()
Output
WAP for Linear Searching in an Array

def search(list,n):

for i in range(len(list)):
if list[i] == n:
return True
return False

list = [1, 2, 'sachin', 4,'Geeks', 6]

n = 'Geeks'

if search(list, n):
print("Found")
else:
print("Not Found")
Output
WAP for Binary Searching in an Array

def binarySearch (arr, l, r, x):


if r >= l:
mid = l + (r - l)/2
if arr[mid] == x:
return mid

elif arr[mid] > x:


return binarySearch(arr, l, mid-1, x)

else:
return binarySearch(arr, mid+1, r, x)

else:
return -1
Output
WAP to Plot Sin Cos Graph
import matplotlib.pyplot as plt
import numpy as np
x=np.arrange(0,10,0.1)
a=np.cos(x)
b=np.sin(x)
plt.plot(x,a,’b’)
plt.plot(x,b,’r’)
plt.show()
Output
WAP to Print String Backward

def bp(sp, n):


if n>0:
print(sg[n], end=’’)
bp(sg, n-1)
elif n==0:
print(sg[0])
s=input(“Enter a string : “)
bp(s, len(s)-1)
Output
SQL COMMANDS
WORKER_ID FIRST_NAME LAST_NAME SALARY JOINING_DATE DEPARTMENT

001 NIHARIKA ARORA 20000 2013-02-25 09:00:00 HR

002 AYUSHI GURONDIA 5000 2015-02-10 09:00:00 ADMIN

003 PRIYANSHA CHOUKSEY 25000 2014-05-16 09:00:00 HR

004 APARNA DESHPANDE 8000 2016-12-20 09:00:00 ADMIN

005 SHAFALI JAIN 21000 2015-08-29 09:00:00 ADMIN

006 SUCHITA JOSHI 20000 2017-02-12 09:00:00 ACCOUNT

007 SHUBHI MISHRA 15000 2018-03-23 09:00:00 ADMIN

008 DEVYANI PATIDAR 18000 2014-05-02 09:00:00 ACCOUNT

TABLE- BONUS
WORKER_REF_ID BONUS_DATE BONUS_AMOUNT

1 2015-04-20 00:00:00 5000


2 2015-08-11 00:00:00 3000
3 2015-04-20 00:00:00 4000

1 2015-04-20 00:00:00 4500


2 2015-08-11 00:00:00 3500

TABLE- TITLE
WORKER_REF_ID WORKER_TITLE AFFECTED_FROM
1 Manager 2016-02-20 00:00:00
2 Executive 2016-06-11 00:00:00

8 Executive 2016-06-11 00:00:00


5 Manager 2016-06-11 00:00:00
4 Asst. Manager 2016-06-11 00:00:00

7 Executive 2016-06-11 00:00:00


6 Lead 2016-06-11 00:00:00
3 Lead 2016-06-11 00:00:00
Q.1 Write an SQL query for fetching “FIRST_NAME” from the WORKER table using
<WORKER_NAME> as alias.
Ans. The query that you can use is:
Select FIRST_NAME AS WORKER_NAME from Worker;
Q.2 What is an SQL Query for fetching the “FIRST_NAME” from WORKER table in
upper case?
Ans. The query that you can use is:
Select upper(FIRST_NAME) from Worker;
Q.3 What is an SQL query for fetching the unique values of the column
DEPARTMENT from the WORKER table?
Ans. The query that you cam use is:
Select distinct DEPARTMENT from Worker;
Q.4 Write an SQL query for printing the first three characters of the column
FIRST_NAME.
Ans. The query that can be used is:
Select substring(FIRST_NAME,1,3) from Worker;
Q.5 What is an SQL query for finding the position of the alphabet (‘A’) in the
FIRST_NAME column of Ayushi.
Ans. The query that can be used is:
Select INSTR(FIRST_NAME, BINARY'a') from Worker where FIRST_NAME = 'Ayushi';
Q.6 What is an SQL Query for printing the FIRST_NAME from Worker Table after the
removal of white spaces from right side.
Ans. The query that can be used is:
Select RTRIM(FIRST_NAME) from Worker;
Q.7 Write an SQL Query for printing the DEPARTMENT from Worker Table after the
removal of white spaces from the left side.
Ans. The query that you can use is:
Select LTRIM(DEPARTMENT) from Worker;
Q.8 What is an SQL query for fetching the unique values from the DEPARTMENT
column and thus printing is the length?
Ans. The query that you can use is:
Select distinct length(DEPARTMENT) from Worker;
Table – EmployeeDetails

EmpId FullName ManagerId DateOfJoining

121 John Snow 321 01/31/2014

321 Walter White 986 01/30/2015

421 Kuldeep Rana 876 27/11/2016

Table – EmployeeSalary

EmpId Project Salary

121 P1 8000

321 P2 1000

421 P1 12000
Ques.1. Write a SQL query to fetch the count of employees working in project
'P1'.
Ans. Here, we would be using aggregate function count() with the SQL where
clause-
SELECT COUNT(*) FROM EmployeeSalary WHERE Project = 'P1';
Ques.2. Write a SQL query to fetch employee names having salary greater
than or equal to 5000 and less than or equal 10000.
Ans. Here, we will use BETWEEN in the 'where' clause to return the empId of
the employees with salary satifying the required criteria and then use it as
subquery to find the fullName of the employee form EmployeeDetails table.
SELECT FullName
FROM EmployeeDetails
WHERE EmpId IN
(SELECT EmpId FROM EmpolyeeSalary
WHERE Salary BETWEEN 5000 AND 10000)
Ques.3. Write a query to fetch employee names and salary records. Return
employee details even if the salary record is not present for the employee.
Ans. Here, we can use left join with EmployeeDetail table on the left side.
SELECT E.FullName, S.Salary
FROM EmployeeDetails E LEFT JOIN EmployeeSalary S
ON E.EmpId = S.EmpId;
Ques.4. Write a SQL query to fetch all the Employees who are also managers
from EmployeeDetails table.
Ans. Here, we have to use Self-Join as the requirement wants us to analyze
the EmployeeDetails table as two different tables, each for Employee and
manager records.
SELECT DISTINCT E.FullName
FROM EmpDetails E
INNER JOIN EmpDetails M
ON E.EmpID = M.ManagerID;
Ques.5. Write a SQL query to fetch all employee records from
EmployeeDetails table who have a salary record in EmployeeSalary table.
Ans. Using 'Exists'-
SELECT * FROM EmployeeDetails E
WHERE EXISTS
(SELECT * FROM EmployeeSalary S WHERE E.EmpId = S.EmpId);
Ques.6. Write a SQL query to fetch duplicate records from a table.
Ans. In order to find duplicate records from table we can use GROUP BY on
all the fields and then use HAVING clause to return only those fields whose
count is greater than 1 i.e. the rows having duplicate records.
SELECT EmpId, Project, Salary, COUNT(*)
FROM EmployeeSalary
GROUP BY EmpId, Project, Salary
HAVING COUNT(*) > 1;
Ques.7. Write a SQL query to remove duplicates from a table without using
temporary table.
Ans. Using Group By and Having clause-
DELETE FROM EmployeeSalary
WHERE EmpId IN (
SELECT EmpId
FROM EmployeeSalary
GROUP BY Project, Salary
HAVING COUNT(*) > 1));
Ques.8. Write a SQL query to fetch only odd rows from table.
Ans. This can be achieved by using Row_number in SQL server-
SELECT E.EmpId, E.Project, E.Salary
FROM (
SELECT *, Row_Number() OVER(ORDER BY EmpId) AS RowNumber
FROM EmployeeSalary
)E
WHERE E.RowNumber % 2 = 1
Table Name:- Employee
Empid EmpName Department ContactNo EmailId EmpHeadId

101 Isha E-101 1234567890 [email protected] 105

102 Priya E-104 1234567890 [email protected] 103

103 Neha E-101 1234567890 [email protected] 101

104 Rahul E-102 1234567890 [email protected] 105

105 Abhishek E-101 1234567890 [email protected] 102

1. Select the detail of the employee whose name start with P.


Ans. select * from employee where empname like 'p%'
2. Select the detail of employee whose emailId is in gmail.
Ans. select * from employee where emaildid like '%@gmail.com'
3.Select the details of the employee who work either for department E-
104 or E-102.
Ans. select * from employee where department='E-102' or
department='E-104'
4.What is the department name for DeptID E-102?
Ans. select deptname from empdept where deptid ='E-102'
5.List name of all employees whose name ends with a.
Ans. select * from employee where empname like '%a'
6.select the name of the employee whose name's 3rd charactor is 'h'.
Ans. select * from employee where empname like '__h%'
7. Select the department name of the company which is assigned to the
employee whose employee id is grater 103.
Ans. select deptname from empdept where deptid in (select
department from employee where empid>103)
8.Select the name of the employee who is working under Abhishek.
Ans. select empname from employee where empheadid =(select empid
from employee where empname='abhishek')
Remarks

Principal:

Teacher:

Examiner:

You might also like