You are on page 1of 44

DELHI PUBLIC SCHOOL

SAIL TOWNSHIP,RANCHI

REPORT FILE
CLASS-XII: COMPUTER SCIENCE (083)

NAME: ABHIJEET GORAI

CLASS: XII H

SCHOOL: DELHI PUBLIC SCHOOL

ROLL NUMBER: 04

BOARD ROLL NUMBER: 22692309

1
ACKNOWLEDGEMENT
I would like to express my special thanks of
gratitude to my Computer Teacher "Mr. Gautam
Chakraborty" for his able guidance and support in
completing this project.

I would also like to extend my gratitude to our


Principal Dr. Ram Singh for providing me with all
the required facilities.

Secondly, I would also like to thank my parents


and friends who helped me a lot in finishing this
project within the limited time. Just because of
them I was able to create my project and make it
good and enjoyable experience.

Thanks again to all who helped me during the


project

2
1. Write a program to enter two numbers and print the
arithmetic operations like +,-,*,/,// and % as per user
choice.
Ans:-

4
2. Write a program to check entered number is Armstrong
or not.

5
3. Write a program to enter the number of terms and to
print the Fibonacci series.

6
4. Write a program to enter the string and display the
longest word present in the entered string.

7
5. Write a python function that takes a number as a
parameter and checks whether a number is prime or
not.

8
6. Write a python function to add the first ‘n’ terms of the
series:
1+1/2-1/3+1/4-1/5+………………………

9
7. Write a program that accepts a hyphen-separated
sequence of words as input and print the words in a
hyphen-separated sequence after storing them
alphabetically.
Sample Items: green-red-yellow-black-white
Expected Result: black-green-red-white-yellow

Output:-

10
8. Write a python function to calculate the factorial of a
number (a non-negative integer). The function accepts
the number whose factorial is to be calculated as the
argument.

11
9. Write a program to remove all the lines that contain the
character “b” in a file and write it into another text file.

Output:-

12
10. Write a program to read a text file and display the
number of vowels/consonants/uppercase/lowercase
characters in the file.

13
11. Write a program to create a binary file with name
and roll no. Search for a given roll number and display
the name, if not found display appropriate message.

14
12. Write a program to create a binary file to store
Rollno, Name and Marks and update marks of entered
Rollno.

15
13. Write a program to implement a stack using a list
data structure.

16
14. Write a program to read a text file line by line and
display each word separated by #.

Output:-

17
15. Write a program to accept string/sentences from
the user till the user enters “END”. Save the data in a
text file and then display only those sentences which
begin with an uppercase alphabet.

Output:-

18
16. Write a program to read a file ‘Story.txt’ and create
another file, storing an index of ‘Story.txt’, telling which
line of the file each words appears in. If word appears
more than once, then index should show all the line
numbers containing the word.

Output:-

19
17. Write a program to display the size of the file after
removing EOL characters, leading and trailing white
spaces and blank lines.

Output:-

20
18. Raj has been asked to display all the students who
have secured less than 40 for Remedial Classes. Write a
user-defined function to display those students who
have secured less than 40 from the binary file
“Student.dat”.

21
19. Write a program to create CSV file and store
empno, name, salary and search any empno and display
name, salary and if not found appropriate message.

Output:-

22
20. Write a menu driven program to implement Stack
in Python using List.

23
21. Write a program to connect with database and
store record of employee and display records.

Output:-

24
22. Write a program to connect with database and
search employee number in table employee and display
record, if empno not found display appropriate
message.

Output:-

25
23. Write a program to connect with database and
update the employee record of entered empno.

Output:-

26
24. Write a program to connect with database and
delete the record of entered employee number.

Output:-

27
25. Create a student table and insert data. Implement
the following SQL commands on the student table:
(a) ALTER table to add new attributes / modify data
type / drop attribute
(b) UPDATE table to modify data
(c) ORDER By to display data in ascending / descending
order
(d) DELETE to remove tuple(s)
(e) GROUP BY and find the min, max, sum, count and
average.

(a) To add new column:

28
To modify data type:

To drop column:

29
(b) To modify data:

(c) Sort data in ascending/descending order

30
(d) To delete tuple

(e) To group records

31
26. Create a table STUDENT and write sql commands for (a) to (f)
and write the outputs for (e) and (g) on the basis of the table
STUDENT:

TABLE: STUDENT
SNO NAME STREAM FEES AGE SEX

1 ARUN COMPUTER 750.00 17 M


KUMAR
2 DIVYA JENEJA COMPUTER 750.00 18 F
3 KESHAR BIOLOGY 500.00 16 M
MEHRA
4 HARISH ENG.DR. 350.00 18 M
SINGH
5 PRACHI ECONOMICS 300.00 19 F
6 NISHA ARORA COMPUTER 750.00 15 F
7 DEEPAK ECONOMICS 300.00 16 M
KUMAR
8 SARIKA BIOLOGY 500.00 15 F
VASWANI

(a )List the name of all students who have taken stream as


COMPUTER.
(b) To count the number of female students.
(c )To display the number of students stream wise.
(d) To insert a new row in the student table :
9, “KARISHMA”, “ECONOMICS”,300,18, “F”.
(e) To display a report, listing NAME, STREAM, SEX and stipend
where stipend is 20% of the fees.
(f) To display all the records in stored order of name.

32
(a) SELECT NAME FROM STUDENT WHERE STREAM=’COMPUTER’;

(b) SELECT COUNT(SEX) FROM STUDENT WHERE SEX=’F’;

33
(c) SELECT STREAM,COUNT(STREAM) FROM STUDENT GROUP BY STREAM;

(d) INSERT INTO STUDENT VALUES(9,’KARISHMA’,’ECONOMICS’,300,18,’F’);

34
(e) ALTER TABLE STUDENT ADD STIPEND INT;
UPDATE STUDENT SET STIPPEND=0.2*FEES;

(f) SELECT * FROM STUDENT ORDER BY SNO;

35
27. Consider the following table named “Softdrink”. Write
commands of SQL for (i) to (iv).

TABLE:SOFTDRINK
DRINKCODE DNAME PRICE CALORIES
101 Lime and Lemon 20.00 120
102 Apple Drink 18.00 120
103 Nature Nectar 15.00 115
104 Green Mango 15.00 140
105 Aam Panna 20.00 135
106 Mango Juice Bahaar 12.00 150

(i) To display names and drink codes of those drinks


that have more than 120 calories.
(ii) To display drink codes, names and calories of all
drinks, in descending order of calories.
(iii) To display names and price of drinks that have price
in the range 12 to 18 (both 12 and 18 included).
(iv) Increase the price of all drinks in the given table by
10%.

(i) SELECT DNAME, DRINKCODE FROM SOFTDRINK WHERE CALORIES>120;

36
(ii) SELECT DRINKCODE,DNAME,CALORIES FROM SOFTDRINK ORDER BY
CALORIES DESC;

(iii) SELECT DNAME,PRICE FROM SOFTDRINK WHERE PRICE BETWEEN 12 AND


18;

(iv) UPDATE SOFTDRINK SET PRICE=PRICE+0.1*PRICE;

37
28. Write a output for SQL queries (i) to (iii), which are
based on the table : student given below:

Table: Student
ROLLNO NAME CLASS DOB GENDER CITY MARKS
1 Nanda X 06-06-1995 M Agra 551
2 Saurabh XII 07-05-1993 M Mumbai 462
3 Sonal XI 06-05-199 F Delhi 400
4
4 Trisla XII 08-08-1995 F Mumbai 450
5 Aman XII 08-10-1995 M Delhi 369
6 Puja XI 12-12-1994 F Dubai 250
7 Neha X 08-12-1995 F Ranchi 377
8 Raj X 12-06-1995 M Ranchi 489

(i) Select count(*), city from student group by city having


count(*)>1;
(ii) Select max(DOB), Min(DOB) from student;
(iii) Select Name, Gender from student where city=’Delhi’;

Write a SQL queries for (i) to (iv), which are based on the
table: student.

(i) To display the records from table student in


alphabetical order as per the name of the student.
(ii) To display Class, DOB and City whose marks is
between 450 and 551.
(iii) To display Name, Class and total number of students
who have secured more than 450 marks, class wise.
(iv) To increase marks of all students by 20 whose class is
‘XII’.

38
(i) Select count(*), city from student group by city having
count(*)>1;

(ii) Select max(DOB), Min(DOB) from student;

(iii) Select Name, Gender from student where city=’Delhi’;

Write a SQL queries for (i) to (iv), which are based on the table:
student.

(i) To display the records from table student in alphabetical


order as per the name of the student

39
(ii) To display Class, DOB and City whose marks is between
450 and 551.
SELECT CLASS,DOB,CITY FROM STUDENT WHERE MARKS BETWEEN 450 AND 551;

(iii) To display Name, Class and total number of students who


have secured more than 450 marks, class wise.
SELECT NAME,CLASS,COUNT(*) FROM STUDENT WHERE MARKS>450 GROUP BY
CLASS;

(iv) To increase marks of all students by 20 whose class is ‘XII’.


UPDATE STUDENT SET MARKS=MARKS+20 WHERE CLASS=’XII’;

40
29. Consider the table CLUB given below.
Table: CLUB
COACH_ID COACH_NAME AGE SPORTS DATEOFAPP PAY SEX

1 KRKREJA 35 KARATE 27/03/1996 1000 M

2 RAVINA 34 KARATE 20/01/1998 1200 F

3 KARAN 34 SQUASH 19/02/1998 2000 M

4 TARUN 33 BASKETBALL 01/01/1998 1500 M

5 ZUBIN 36 SWIMMING 12/01/1998 750 M

6 KETKI 36 SWIMMING 24/02/1998 800 F

7 ANKITA 39 SQUASH 20/02/1998 2200 F

8 KUSH 37 KARATE 22/02/1998 1100 F

9 SHAILYA 41 SWIMMING 13/01/1998 900 M

10 39 BASKETBALL 19/02/1998 1700 M

Write the output of the queries (a) to (d) based on the table,
CLUB given above:

i) SELECT COUNT (DISTINCT SPORTS) FROM CLUB;


ii) SELECT MIN(AGE) FROM CLUB WHERE SEX = ‘F’;
iii) SELECT AVG(PAY) FROM CLUB WHERE SPORTS = ‘KARATE’;
iv) SELECT SUM(PAY) FROM CLUB WHERE DATEOFAPP >
‘31/01/1998’;

41
(i) SELECT COUNT (DISTINCT SPORTS) FROM CLUB;

(ii) SELECT MIN(AGE) FROM CLUB WHERE SEX = ‘F’;

(iii) SELECT AVG(PAY) FROM CLUB WHERE SPORTS = ‘KARATE’;

(iv) SELECT SUM(PAY) FROM CLUB WHERE DATEOFAPP >


‘31/01/1998’;

42
30. Write SQL commands for the following queries (i) to
(iv) based on the relations Product and Client given below:
Table: Product

P_ID ProductName Manufacturer Price Discount

Talcum
TP01 LAK 40
Powder

FW05 Face Wash ABC 45 5

BS01 Bath Soap ABC 55

SH06 Shampoo XYZ 120 10

FW12 Face Wash XYZ 95

Table: Client

C_ID ClientName City P_ID

01 Cosmetic Shop Delhi TP01

02 Total Health Mumbai FW05

03 Live Life Delhi BS01

04 Pretty Woman Delhi SH06

05 Dreams Delhi TP01

43
i) Write SQL query to display ProductName and Price for all
products whose Price is in the range of 50 to 150.
ii) Write SQL query to display details of product whose
manufacturer is either XYZ or ABC
iii) Write SQL query to display ProductName, Manufacturer
and Price for all Products that are not given any discount.
iv) Write SQL query to display ClientName, City, and P_ID
for all clients whose city is Delhi.
(i) SELECT PRODUCTNAME,PRICE FROM PRODUCT WHERE PRICE BETWEEN
50 AND 150;

(ii) SELECT * FROM PRODUCT WHERE MANUFACTURER=’XYZ’ OR


MANUFACTURER=’ABC’;

44
(iii) SELECT PRODUCT_NAME,MANUFACTURER,PRICE FROM PRODUCT
WHERE DISCOUNT IS NULL;

(iv) SELECT CLIENT_NAME,CITY,P_ID FROM CLIENT WHERE CITY=’DELHI’;

45

You might also like