Grade 11 Prac

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 51

CBSE SENIOR SECONDARY SCHOOL,TIRUPUR

COMPUTER SCIENCE WITH PYTHON (083)

AISSCE PRACTICAL FILE’20

1
CERTIFICATE

Certified that the entries in this project file is the bonafide work of

Master / Ms. : _________________________________

Grade : _________________________________

Exam No. : _________________________________

Completed during the academic year 2019-20

This project file was submitted for the AISSE (Class XI) 2020

Practical examination in Computer Science conducted on _______________

______________________________ ____________________________

(Signature of Internal Examiner) (Signature of the Principal)

2
INDEX

S. NO TITLE OF PROGRAMS PG. NO. T.SIGN

1 FIBONACCI SERIES 4

2 SWAP 2 NUMBERS 6

3 AREA OF A TRIANGLE 9

4 GREATEST AMONG THREE NUMBERS 11

5 LEAP YEAR 13

6 FACTORIAL OF A NUMBER 15

7 COUNT THE NUMBER OF VOWELS IN STRING 17

8 PRIME NUMBER 20

9 STRING IS PALINDROME OR NOT 22

10 ARMSTRONG NUMBER 24

11 SMALLEST AND LARGEST NUMBER IN A LIST 26

12 REMOVE DUPLICATE ITEMS 28

13 BUBBLE SORT 30

14 INSERTION SORT 32

15 COUNT NUMBER OF CHARACTER IN SENTENCE 34

16 EMPLOYEE SALARY CALCULATION 36

17 ADDITION OF ELEMENTS IN LIST 38

18 EVEN OR ODD IN A LIST 41

19 SQL-1 43

20 SQL-2 47

3
1.FIBONACCI SERIES

AIM:

To print Fibonacci series 0,1,1,2,3,5,8,13……..

ALGORITHM:

STEP 1: Start

STEP 2: Input enter number n

STEP 3: Check condition

While c<=n

STEP 4: Stop

PROGRAM:

n=int(input("Enter the number:"))

a=0

b=1

c=a+b

print(a)

print(b)

while c<=n:

print(c)

a=b

4
b=c

c=a+b

OUTPUT:

RESULT:

Thus the program is executed and the output is verified.

5
2. SWAP 2 NUMBERS

AIM: To swap 2 numbers

ALGORITHM:

STEP 1: Start

STEP 2: Input enters value a and b:

STEP 3: Check condition:

temp=a

a=b

b=temp

STEP 4: Stop

METHOD I

a=int(input("Enter value of a"))

b=int(input("Enter value of b"))

temp=a

a=b

b=temp

print("After swapping")

print("Value of a:",a)

print("Value of b:",b)

6
OUTPUT:

METHOD II

ALGORITHM:

STEP 1: Start

STEP 2: Enter values a and b

STEP 3: Check condition:

a=a+b

b=a-b

a=a-b

STEP 4: Stop

PROGRAM:

a=int(input("Enter value of a"))

7
b=int(input("Enter value of b"))

a=a+b

b=a-b

a=a-b

print("After Swapping")

print("Value of a:",a)

print("Value of b:",b)

OUTPUT:

RESULT:

Thus the program is executed and the output is verified.

8
3.AREA OF A TRIANGLE

AIM: To find the area of a triangle

ALGORITHM:

STEP 1: Start

STEP 2: Input enter any number

STEP 3: Check condition:

s=(a+b+c)/2

area=(s*(s-a)*(s-b)*(s-c))**0.5

STEP 4: Stop

PROGRAM:

a=int(input("Enter any number"))

b=int(input("Enter any number"))

c=int(input("Enter any number"))

s=(a+b+c)/2

area=(s*(s-a)*(s-b)*(s-c))**0.5

print("The area of triangle is",area)

9
OUTPUT:

RESULT:

Thus the program is executed and the output is verified.

10
4.GREATEST AMONG THREE NUMBERS

AIM: To find the greatest among three numbers

ALGORITHM:
STEP 1: Start
STEP 2: Input three numbers
STEP 3: Check condition:
if a>b:
if a>c:
if b>c:
STEP 4: Stop

PROGRAM:
a = int(input("Enter 1st number"))
b = int(input("Enter 2nd number"))
c = int(input("Enter 3rd number"))
if a>b:
if a>c:
print ("%d is greatest" % (a))
else:
print ("%d is greatest" % (c))
else:
if b>c:
print ("%d is greatest" % (b))
else:
print ("%d is greatest" % (c))

11
OUTPUT:

RESULT:
Thus the program is executed and the output is verified.

12
5.LEAP YEAR

AIM
To check whether the given year is leap year

ALGORITHM
STEP 1: Start
STEP 2: Input year
STEP 3: Check Condition
if year%100= = 0
year%4 = = 0
STEP 4: Stop

PROGRAM:
year=int(input("Enter year to be checked:"))
if(year%4==0 and year%100!=0 ):
print("The year is a leap year!")
else:
print("The year isn't a leap year!")

13
OUTPUT:

RESULT:

Thus the program is executed and the output is verified.

14
6. FACTORIAL OF GIVEN NUMBER

AIM:

To find the factorial of a given number

ALGORITHM:

STEP 1: Start

STEP 2: Input number

STEP 3: Do iteration according to range:

STEP 4: Stop

PROGRAM:

n=int(input("Enter number:"))

result=1

for i in range(n,0,-1):

result=result*i

print("factorial of",n,"is",result)

15
OUTPUT:

RESULT:

Thus the program is executed and the output is verified.

16
7. COUNT THE NUMBER OF VOWELS IN THE STRING

AI M:

To count the number of vowels in the string

ALGORITHM:

STEP 1: Start

STEP 2: Input string value

STEP 3: check iteration given

STEP 4: Stop

PROGRAM:

string=input("enter string:")

vowels=0

for i in string:

if(i=='a' or i=='e' or i=='i' or i=='o' or i=='u' or i=='a' or i=='e' or i=='i' or i=='o'


or i=='u'):

vowels=vowels+1

print("Number of vowels are:")

print(vowels)

17
OUTPUT:

Using List

sentence=input("Enter the sentence")

string=sentence.lower()

print(string)

count=0

list1=["a","e","i","o","u"]

for char in string:

if char in list1:

count=count+1

18
print("Number of vowels in given sentence",count)

RESULT:

Thus the program is executed and the output is verified.

19
8. PRIME NUMBER

AIM:

To check prime number

ALGORITHM:

STEP 1: Start

STEP 2: Input any number

STEP 3: Do iteration for the entered number

STEP 4: Stop

PROGRAM:

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

for i in range(2, num):

if num % i == 0:

print("not prime number")

break

else:

print("prime number")

20
OUTPUT:

RESULT:

Thus the program is executed and the output is verified.

21
9. STRING IS PALINDROME OR NOT

AIM:

To find a string is palindrome or not

ALGORITHM:

Step 1: Start

Step 2: Input the string value

Step 3: Check iteration for the given input

Step 4: Stop

PROGRAM:

string=input("Enter the string")

rev_string=string[::-1]

print("Reversed string:",rev_string)

if string==rev_string:

print("String is palindrome")

else:

print("String is not palindrome")

22
OUTPUT:

RESULT:

Thus the program is executed and the output is verified.

23
10. ARMSTRONG NUMBER:

AIM:

To find the Armstrong number

ALGORITHM:

STEP 1: Start

STEP 2: Input range number

STEP 3: Do iteration

STEP 4: Stop

PROGRAM:

for i in range(1001):

num=i

result=0

n=len(str(i))

while(i!=0):

digit=i%10

result=result+digit**n

i=i//10

if num==result:

24
print(num)

OUTPUT:

RESULT:

Thus the program is executed and the output is verified.

25
11. LARGEST AND SMALLEST NUMBERS

AIM:

To display the largest and smallest numbers which prompt 10 numbers

ALGORITHM:

STEP 1: Start

STEP 2: Input the numbers

STEP 3: Check iteration

STEP 4: Stop

PROGRAM:

lst = []

num = int(input('How many numbers: '))

for n in range(num):

numbers = int(input('Enter number '))

lst.append(numbers)

print("Maximum Element in the list is :", max(lst), "\nMinimum element in the list
is :", min(lst))

26
OUTPUT:

RESULT:

Thus the program is executed and output is verified.

27
12. REMOVE DUPLICATE ITEMS FROM LIST

AIM:

To remove duplicate items from list of elements

ALGORITHM:

STEP 1: Start

STEP 2: Input number of elements

STEP 3: Do iteration

STEP 4: Stop

PROGRAM:

a=[]

n=int(input("Enter number of elements in list"))

for x in range(0,n):

element=int(input("Enter element:" + str(x+1) +":"))

a.append(element)

b=set()

uni=[]

for x in a:

if x not in b:

28
uni.append(x)

b.add(x)

print("non dul elemnts")

print(uni)

OUTPUT:

RESULT:

Thus program is executed and output is verified

29
13. BUBBLE SORT

AIM:

To list the elements using bubble sort

ALGORITHM:

STEP 1: Start

STEP 2: Input the list

STEP 3: check condition satisfying bubble sort

STEP 4: Stop

PROGRAM:

list=[10,15,4,23,0]

print("Unsorted List:",list)

for j in range(len(list)-1):

for i in range(len(list)-1):

if list[i]>list[i+1]:

list[i],list[i+1]=list[i+1],list[i]

print(list)

print("Sorted List:",list)

30
OUTPUT:

RESULT:

Thus the program is executed and output is verified.

31
14. INSERTION SORT

AIM:

To list the element using insertion sort

ALGORITHM:

STEP 1: Start

STEP 2: Input the list items

STEP 3: Check the condition satisfying insertion sort

Step 4: Stop

PROGRAM:

def insertionsort(list1):

for index in range(1,len(list1)):

cur=list1[index]

pos=index

while cur<list1[pos-1] and pos>0:

list1[pos]=list1[pos-1]

pos=pos-1

list1[pos]=cur

32
list2=[2,4,3,5,1]

insertionsort(list2)

print(list2)

OUTPUT:

RESULT:

Thus program is executed output is verified.

33
15. COUNT NO OF CHARACTERS IN SENTENCE

AIM:

To count no of character n digit in sentence

ALGORITHM:

STEP 1: Start

STEP 2: Input string value

STEP 3: Check given iteration to satisfy the given condition

STEP 4: Stop

PROGRAM:

string=input("Enter string:")

count1=0

count2=0

for i in string:

if(i.isdigit()):

count1=count1+1

count2=count2+1

print("The number of digit is:",count1)

print("The number of characters is:",count2)

34
OUTPUT:

RESULT:

Thus the program is executed and output is verified.

35
16. EMPLOYEE SALARY CALCULATION

AIM:

To calculate the employee salary

ALGORITHM:

STEP 1: Start

STEP 2: Input the required names

STEP 3: Calculate the given employee salary

STEP 4: Stop

PROGRAM:

e_name=input("Enter the name of Employee \n")

c_name=input("Enter the company name \n")

salary=float(input("Enter the salary of Employee \n"))

if(salary>50000):

tax=0.15*salary

netsalary=salary-tax

print("The net salary of "+e_name+" worked in " +c_name+ " is",netsalary)

else:

netsalary=salary

36
print("No taxalbe Amount")

print("The net salary of "+e_name+" worked in " +c_name+ " is",salary)

OUTPUT:

RESULT:

Thus the program is executed and output is verified.

37
17. ADDITION OF ELEMENTS IN LIST

AIM:

To demonstrate addition of elements in a list

ALGORITHM:

STEP 1: Start

STEP 2: Input the elements of the list

STEP 3: Check the elements satisfying the given condition

STEP 4: Stop

PROGRAM:

# Creating a List

List = []

print("Initial blank List: ")

print(List)

# Addition of Elements

# in the List

List.append(1)

List.append(2)

List.append(4)

38
print("\nList after Addition of Three elements: ")

print(List)

# Adding elements to the List

# using Iterator

for i in range(1, 4):

List.append(i)

print("\nList after Addition of elements from 1-3: ")

print(List)

# Adding Tuples to the List

List.append((5, 6))

print("\nList after Addition of a Tuple: ")

print(List)

# Addition of List to a List

List2 = ['For', 'Geeks']

List.append(List2)

print("\nList after Addition of a List: ")

print(List)

39
OUTPUT:

RESULT:

Thus program is executed and output is verified.

40
18. EVEN OR ODD IN A LIST INTO TWO DIFFERENT LIST

AIM:

To check for even or odd in a list into two different list

ALGORITHM:

STEP 1: Start

STEP 2: Enter number n

STEP 3: Check condition:

j%2==0

STEP4: Append

STEP 5: Stop

PROGRAM:

a=[]

n=int(input("Enter number of elements"))

for i in range(1,n+1):

b=int(input("Enter elements:"))

a.append(b)

even=[]

odd=[]

for j in a:

41
if(j%2==0):

even.append(j)

else:

odd.append(j)

print("The Even List",even)

print("The Odd List",odd)

OUTPUT:

RESULT:

Thus program is executed and output is verified.

42
19.DDL COMMANDS
AIM:
Implementing DDL commands.
a)Create table EMP with necessary columns(EMPNO,EMPNAME,
JOB,DOJ,SAL,COMM) with EMPNO as primary key
CREATE TABLE EMP(EMPNO INTEGER NOT NULL PRIMARY
KEY,EMPNAME CHAR(20) NOT NULL,JOB CHAR(20),DOJ
DATE,SAL INTEGER ,COMM INTEGER);

b) Add a column DEPTNO to the already created EMP table.


ALTER TABLE EMP ADD DEPTNO INTEGER;

c)Drop table EMP


DROP TABLE EMP;

DML COMMANDS( SELECT COMMAND)


AIM :
Implementing SELECT commands.
1. Query to display all the records from EMP table.
SELECT * FROM EMP;
2. Query to display EMPNAME,SAL,Salary added with COMM from EMP
table.
SELECT EMPNO,SAL,SAL+COMM AS TOTAL FROM EMP ;
3. Query to display EMPNAME,SAL*12 as TOTAL SALARY from EMP
table.
SELECT EMPNAME,SAL*12 as TOTALSALARY FROM EMP;

43
4. Query to display EMPNAME,Salary of employees whose SAL greater than
or equal to 3000 from EMP table.
SELECT EMPNAME,SAL FROM EMP WHERE SAL>=3000 ;
5. Query to display EMPNAME,SAL of those people who do not have their
salaries in the range of 1500-2000.
SELECT EMPNAME,SAL FROM EMP WHERE SAL NOT
BETWEEN 1500 AND 2000;
6. Query to display the EMPNAME,JOB,SAL of employees from EMP table
who is not a mangager.
SELECT EMPNAME,JOB,SAL FROM EMP WHERE NOT
JOB='MANAGER';
7. Query to display the EMPNAME,SAL AND DEPTNO who are not getting
commission from table EMP.
SELECT EMPNAME,SAL,DEPTNO FROM EMP WHERE
COMM IS NULL;
8. Query to display the name of employee and other details where name
contains ‘a’ as the third alphabet.
SELECT * FROM EMP WHERE EMPNAME LIKE '__a%';
9. Query to display the name of employee and other details where name
contains ‘M’ as the third alphabet and L as the third alphabet.
SELECT * FROM EMP WHERE EMPNAME LIKE '%t';
10.Query to display the name of employee who is having ‘e’ as any alphabet of
the name.
SELECT * FROM EMP WHERE EMPNAME LIKE 'M_L%';

44
DML ( INSERT, UPDATE AND DELETE) COMMANDS
AIM:
Implementing Insert, Update and Delete commands.
Insert the values into the EMP table.
INSERT INTO EMP VALUES(7839,'KING','PRESIDENT','17-
NOV-81',5000,NULL,10);
INSERT INTO EMP VALUES(7698,'BLAKE','MANAGER','01-
MAY-81',2850,NULL,30);
INSERT INTO EMP VALUES(7782,'CLARK','MANAGER','09-
JUN-81',2450,NULL,10);
INSERT INTO EMP VALUES(7566,'JONES','MANAGER','02-
APR-81',2975,NULL,20);
INSERT INTO EMP VALUES(7654,'MARTIN','SALESMAN','28-
FEB-81',1250,1400,30);
INSERT INTO EMP VALUES(7499,'ALLEN','SALESMAN','20-
FEB-81',1600,300,30);
INSERT INTO EMP VALUES(7900,'JAMES','CLERK','03-DEC-
81',950,NULL,30);
INSERT INTO EMP VALUES(7902,'FORD','ANALYST','22-FEB-
81',3000,NULL,NULL);
INSERT INTO EMP VALUES(7788,'SCOTT','ANALYST','09-DEC-
81',3000,NULL,20);
1. Increase the SALARY of all the employees by Rs.1000 .
UPDATE EMP SET SAL=SAL+1000;
2. Increase the COMM of the employees by 100 whose JOB=SALESMAN
UPDATE EMP SET COMM=COMM + 100 WHERE

45
JOB='SALESMAN';
3. Remove the tuples from EMP that have SALARY less than 3000.00.
DELETE FROM EMP WHERE SAL<=3000;

OTHER SQL COMMANDS

1. Create a view from EMP table whose job =Manager


CREATE VIEW EMPMANAGER AS SELECT * FROM EMP
WHERE JOB='MANAGER';
SELECT * FROM EMPMANAGER;
2. To find the maximum value
SELECT MAX (SAL) FROM EMP;
3. To find count total number of rows in a table
SELECT COUNT (*) FROM EMP WHOSE JOB=’MANAGER’;
4. To find the total of all values
SELECT SUM (SALARY) FROM EMP;
5. select job,count(*),sum(comm) from emp group by job;
6. select job,count(*),sum(comm) from emp group by job having count(*)<2;
7. To get the current sysdate
select getdate();
8. To convert upper case to lowercase
select lower('HELLO');
9. To convert lower case to uppercase
select upper('computer');
10.To find the substring
select substring ('POINTER',3,2);

46
20.SQL - DDL COMMANDS

AIM:
Implementing DDL commands.

1) To create a database named payroll


create database payroll;

2) To view the available databases;


show databases;

3) To Create table EMP with necessary columns(EMPNO,EMPNAME, JOB,DOJ


not null,SAL,COMM) with EMPNO as primary key
CREATE TABLE EMP (EMPNO INTEGER PRIMARY KEY,EMPNAME
CHAR(20) ,JOB CHAR(20),DOJ DATE not null ,SAL INTEGER ,COMM
INTEGER);

4) To display the structure of the EMP table


desc / describe emp;

5) To view the available tables in the database


show tables;

6) Add a column DEPTNO to the already created EMP table.


ALTER TABLE EMP ADD DEPTNO INTEGER;

7) To change the datatype of the field eno as varchar(20)


Alter table emp modify eno varchar(20);

8) Drop table EMP


DROP TABLE EMP;

47
DML ( INSERT, UPDATE AND DELETE) COMMANDS
AIM:
Implementing Insert, Update and Delete commands.

1. Insert the values into the EMP table.


INSERT INTO EMP VALUES(7839,'KING','PRESIDENT','17-NOV-
81',5000,NULL,10);
INSERT INTO EMP VALUES(7698,'BLAKE','MANAGER','01-MAY-
81',2850,NULL,30);
INSERT INTO EMP VALUES(7782,'CLARK','MANAGER','09-JUN-
81',2450,NULL,10);
INSERT INTO EMP VALUES(7566,'JONES','MANAGER','02-APR-
81',2975,NULL,20);
INSERT INTO EMP VALUES(7654,'MARTIN','SALESMAN','28-FEB-
81',1250,1400,30);

2. Increase the SALARY of all the employees by Rs.1000 .


UPDATE EMP SET SAL=SAL+1000;

3. Increase the COMM of the employees by 100 whose JOB=SALESMAN


UPDATE EMP SET COMM=COMM + 100 WHERE
JOB='SALESMAN';

4. Remove the tuples from EMP that have SALARY less than 3000.00.
DELETE FROM EMP WHERE SAL<=3000;

48
DML COMMAND( SELECT COMMAND)
AIM :
Implementing SELECT commands.

1. To display all the records from EMP table.


SELECT * FROM EMP;

2. To display EMPNAME,SAL,Salary added with COMM from EMP table.


SELECT EMPNO,SAL,SAL+COMM AS TOTAL FROM EMP ;

3. To display EMPNAME,SAL*12 as TOTAL SALARY from EMP table.


SELECT EMPNAME,SAL*12 as TOTALSALARY FROM EMP;

4. To display EMPNAME,Salary of employees whose SAL greater than or equal


to 3000 from EMP table.
SELECT EMPNAME,SAL FROM EMP WHERE SAL>=3000 ;

5. To display EMPNAME,SAL of those people who do not have their salaries in


the range of 1500-2000.
SELECT EMPNAME,SAL FROM EMP WHERE SAL NOT BETWEEN
1500 AND 2000;

6. To display the EMPNAME,JOB,SAL of employees from EMP table who is


not a mangager.
SELECT EMPNAME,JOB,SAL FROM EMP WHERE NOT
JOB='MANAGER';

7. To display the EMPNAME,SAL AND DEPTNO who are not getting


commission from table EMP.
SELECT EMPNAME,SAL,DEPTNO FROM EMP WHERE COMM

49
IS NULL;

8. To display the name of employee and other details where name contains ‘a’ as
the third alphabet.
SELECT * FROM EMP WHERE EMPNAME LIKE '__a%';

9. To display the name of employee and other details where name contains ‘M’ as
the third alphabet and L as the third alphabet.
SELECT * FROM EMP WHERE EMPNAME LIKE '%t';

10.To display all details of female employee based on their salary in descending
order.
SELECT * FROM EMP WHERE sex=’f’ order by sal desc;

OTHER SQL COMMANDS

1. Create a view from EMP table whose job =Manager


CREATE VIEW EMPMANAGER AS SELECT * FROM EMP
WHERE JOB='MANAGER';
SELECT * FROM EMPMANAGER;
2. To find the maximum value
SELECT MAX (SAL) FROM EMP;
3. To find count total number of rows in a table
SELECT COUNT (*) FROM EMP WHOSE JOB=’MANAGER’;
To find list of employees joined in 2000
SELECT ename,eno,doj from EMP where (year(doj) !=2000);
4. To display job,commission of employess based on their dept
select job,count(*),sum(comm) from emp group by dept;

50
5. To get the current sysdate
select getdate();
6. To convert upper case to lowercase
select lower('HELLO');
7. To convert lower case to uppercase
select upper('computer');

8. To repeat the given character expression


select replicate('*#',4);
9. To find the substring
select substring ('POINTER',3,2);

51

You might also like