You are on page 1of 100

COMPUTER SCIENCE

PRACTICAL FILE

MADE BY- KHWAISH JARANGAL


CLASS- XII-A
GRADE 11
QUESTIONS
INDEX GRADE XI
S.No TOPIC Page
No
1. Write a program to calculate simple interest. 1

2. Write a program to take an input from the user and display whether the number 2
is odd or even.
3. Write a program to input marks in 5 different subjects and calculate their 3
percentage.
4. Write a program to enter name and age of person and display whether the person 4
is eligible to vote.
5. Write a program to find out Fibonacci series up to a certain number. 5

6. Define the function to find the factorial of a number and use that function in a 6
program
7. Write a program that searches for prime number from 15-25 7
8. Write a program to input 3 numbers and display the largest number. 8
9. Write a program to check whether the year entered by the user is a leap year or not. 9
10. Write a program to find sum of digits of number entered by the user. 10
11. Write a program to find the grade of a student. If a child score 90% A grade, 80%-90% B 11
grade, 70%-80% C grade, 60%-70 D grade and below 60% fail.
12. Write a program to input two strings. If string 1 is contained in string 2 then create a third 12
string which contains the first four characters of string 2.
13. Write a program to input a string and check whether it is palindrome or not. 13
14. Write a program that reads a line and then prints number of uppercase and lowercase 14
characters.
15. Write a program to input a string with some digits and then print sum of the digits. 15
16. Write a program to input a tuple and create two new types from it, one containing its 16
every third element in reverse order, starting from the last element, other containing
every alternate element from third to ninth.
17. Write a program to input a tuple and check if it contains all the elements as same. 17
18. Write a program to check whether all elements of the tuple are in descending order or 18
not.
19. A tuple stores marks of 5 subject of a student. Write a program to find the grade of a 19
student.
20. Write a program to input n names from a student. Also input a name of a student from 20
the user and find if it’s in the tuple or not.
21. Write a program to delete keys of a dictionary one by one in LIFO order. Make sure there 21
is no error generated in when the last item is deleted.
22. Write a program to find highest two values in a dictionary. 22
23. Write a program to create a dictionary from a string. 23
24. Write a program that displays options for inserting and deleting elements from a list. If 24
the user chooses a deletion option display a submenu and ask if the element is to be
deleted by value or by using its slice is to be deleted.
25. Write a program to find minimum element of a list along with its index. 25

26. Write a program to search for an element in a given list of numbers. 26


27. Write a program to find frequency of a given element in a list of numbers. 27
Q.1 Write a program to calculate Simple Interest.

INPUT

OUPUT
Q.2 Write a program to take an input from the user and display whether the
entered number is odd or even.
OUTPUT

INPUT
Q.3 Write a program to input marks in 5 different subjects and calculate their
percentage.
INPUT

OUTPUT
Q.4 Write a program to enter age and name of person and display the
message whether the person is eligible to vote or not.
INPUT

OUTPUT
Q.5 Write a program to find out Fibonacci series up to a certain number.
INPUT

OUTPUT
Q.6 Define the function to find the factorial of a number and use the function
in a program.
INPUT

OUTPUT
Q.7 Write a program that searches for prime number between 15 to 25.
INPUT

OUTPUT
Q.8 Write a program to input 3 numbers and display the largest number.
INPUT

OUTPUT
Q.9 Write a program to check whether the year entered by the user is leap
year or not.
INPUT

OUTPUT
Q.10 Write a program to find sum of digits of number entered by the user.
INPUT

OUTPUT
Q.11 Write a program to find grade of a student. If a child is getting above
90% A grade, 80%-90% B grade, 80%-70% C grade, 70%-60% D grade and
below 60% fail.
INPUT

OUTPUT
Q.12 Write a program to input two strings, if string 1 is contained in string 2,
then create a third string with first four characters of string 2 would restore.
INPUT

OUTPUT
Q.13 Write a program to input a string and check whether it is palindrome or
not.
INPUT

OUTPUT
Q.14 Write a program that reads a line and then prints number of uppercase,
lowercase characters and digits.
INPUT

OUTPUT
Q.15 Write a program to input a string with some digits and find the sum of
those digits.
INPUT

OUTPUT
Q.16 Write a program to input a tuple and create two new types from it, one
containing its every third element in reverse order, starting from the last
element, another containing every alternate element between third to ninth
element.
INPUT

OUTPUT
Q.17 Write a program to input a tuple and check if it contains all elements as
same.
INPUT

OUTPUT
Q.18 Write a program to check if all the elements of a tuple are in descending
order or not.
INPUT

OUTPUT
Q.19 A tuple stores marks of a student in 5 subjects. Write a program to
calculate the grade of the student.
INPUT

OUTPUT
Q.20 Write a program to input names of n students and store them in a tuple.
Also, input a name from the user and find if this student is present in the
tuple or not.
INPUT

OUTPUT
Q.21 Write a program to delete the keys of a dictionary one by one in LIFO
order. Make sure that there is no error generated after the last item.
INPUT

OUTPUT
Q.22 Write a program to find highest 2 values in a dictionary.
INPUT

OUTPUT
Q.23 Write a program to create a dictionary from a string.
INPUT

OUTPUT
Q.24 Write a program that displays options for inserting or deleting elements
in a list. If the user chooses a deletion option, display a submenu and ask if
element is to be deleted with value or by using its slice is to be deleted.
INPUT

OUTPUT
Q.25 Write a program to find minimum element of a list along with its index.
INPUT

OUTPUT
Q.26 Write a program search for an element in a given list of numbers.
INPUT

OUTPUT
Q.27 Write a program to count the frequency of a given element in a list of
numbers.
INPUT

OUTPUT
GRADE 12
QUESTIONS
INDEX GRADE XII
S.No TOPIC Page
NO.
1. Write a program to calculate simple interest using the function. Specify detail value of 39
rate=10% and time= 2 years

2. Write a function to check whether a number is perfect or not. 40


3. Write a function to reverse a string. 41
4. Write a function to find square root of a number. 42
5. Write a function to return sum of multiple numbers. 43
6. Write a function to return sum of 3 numbers. 44
7. Write a random number generator that generates number from 1-6. 45
8. Write a function that takes a positive number and returns the one’s position of the digit. 46
9. Write a recursive code to find factorial of a number. 47
10. Write a function to perform binary search in sorted list. 48
11. Write a function using recursive code to find Fibonacci series till n terms. 49
12. Write a program to insert and delete operations on a queue containing member details 50
such as member number, member name and member age.
13. Write a program to implement stack of book details, each of details contain book name 51
and book number. Apply PUSH, POP and DISPLAY operations.
14. Write a program to sort list using bubble sort. 52
15. Write a program to sort using insertion sort. 53
16. Write a program to read a text file line by line and display each word separated by ‘#’. 54
17. Write a program to read a text file and display the number of vowels and consonants in 55
the file.
18. Write a program to get the marks, name and roll number of a student and store these 56
details in a file called marks.txt.
19. Consider the binary file Stu.dat containing student detail. Write a program to update the 57
records the file so that who scored more than 81 gets additional marks of 2.
20. Write a program to open a binary file and search for records having roll number 12 and 58
14.
21. Write a program to get item details (code, description and price) for multiple items from 59
user and create a csv file by writing all item details in one go.
22. Write a program to display the number of lines in a file. 60
S.NO TABLE QUESTION PAGE NO.
1. STUDENT 62

1.1 WAQ to display name, roll no and


aggregate divided by 5. Name
column aggregate divided by 5 as
percentage
1.2 WAQ that produces result as student
name, aggregate, age
2. STUDENT MARKS 63

2.1 WAQ to display name, age and marks


of student whose age is greater or
equal to 16 from student table
3. PETS 64

3.1 WAQ that display all the details from


pet table for species cat or dog and
gender as male.
4. EMPL 65
4.1 Display all records from the table
empl
4.2 Display Empno and Ename of all
employees
4.3 Display Ename, Sal, Sal added with
Comm
4.4 Write a query to ename, salary,
deptno who are not getting
commision
4.5 Write a query to empno, ename, sal,
sal*12 as Annual Salary whose
commison is not null
4.6 List all department numbers

4.7 List of all unique department


numbers
4.8 List details of all the clerks who have
not been assigned department
4.9 List details of employees who have 4
lettered names
4.10 List details of employees whose
annual salary between 25000-40000
4.11 How many types of jobs are offered
to employees?
4.12 List details of all employees who
earn more commission than their
salary
4.13 Write a query to display name, job
title and salary of employee who
does not have manager
4.14 Write a query to display name of
employees whose name contain ‘A’
as third alphabet
4.15 Write a query to display name of
employees whose name contain ‘T’
as last alphabet
4.16 Write a query to display name of
employees whose name contain ‘L’
as any alphabet
5. SPORTS 69
5.1 Display the names of student who
have grade ‘C’ in either Game 1 or
Game 2
5.2 Display the names of student who
have same game for Game1 and
Game2
5.3 Display games taken up by students,
whose name starts with ‘A’
6. STUDENT 70
6.1 Display minimum avg marks where
avg marks < 75
6.2 Display sum of stipend where grade
is ‘B’
6.3 Display avg of stipend where class is
‘12A’
6.4 Display number of fields

7. EMPLOYEE 72
7.1 Create table.

7.2 For record with ID = 4 update


Last_Name, User_ID and Salary to
‘Sahukar’, ‘skar’, 9000
7.3 Display number of fields

7.4 Modify the last name, of employee 3,


to Gautam
7.5 Modify salary and increase it by
1000, for all who get salary < 5000
7.6 Delete Employee having first name
‘Siddharth’
7.7 Remove entire content of the table

8. STUDENT 74
8.1 Display records in alphabetical order
as per name of student
8.2 Display Class, DOB and City whose
marks between 450 and 551
8.3 Display Class and total students who
secured more than 450 marks
8.4 To increase marks of all students by
20 who are in class 12
9. STUDENT_RELATIO 76
N
9.1 To show all information of student in
history department
9.2 To list name of female students who
are in Hindi department
9.3 To list name of all the students with
there date of admission in ascending
order
9.4 To display Name, age and fees for
male students only
9.5 To count number of students with
age < 23
9.6 To insert row in student with
following data: -
9,”Zaheer”,36,”Computer”,1997-03-
12,230,’M’
10. DEPT AND WORKER 78
10.1 To display wno, name, gender in
descending order
10.2 To name of all female workers in
workers table
10.3 To display name and wno of those
workers who are born between
‘1987-01-01’ and ‘1986-01-01’
10.4 To count and display all male
workers who joined after ‘1986-01-
01’
10.5 To count number of workers in more
than one dept, dept wise
10.6 To display number of distinct dept
from dept table
10.7 To display name, department and
city of workers with wno < 1003 and
dcode common in workers and dept
table
11. STUDENT_DATA 81
11.1 Display information of students in 11
B
11.2 Display 11th and 12th class student
information
11.3 Display student information who are
not in class 10
11.4 Display total fees paid

11.5 Display average of total fees paid

11.6 Display max fees

11.7 Display min fees

11.8 Display total number of students

12. EMPLOYEE_2 83
12.1 Add primary key constraint to ID
column
12.2 Add foreign key constraint that will
ensure record with invalid
department are prohibited
12.3 Add not null constraint to empname

12.4 Drop the table

13. CUSTOMER 84
13.1 Add one column Email: Varchar (30)

13.2 Change datatype of column Zip code


to Varchar (10)
NON-TABLE
QUESTIONS
14 Display 4 characters extracted from 85
3rd left character onwards from
‘abcdefg’
15 Display first three characters 86
extracted from jobs of emp 8888 or
8900
16 Remove leading and trailing spaces 87
from ‘ Bar one ‘
17 How many characters are there in 88
‘CANDIE’
18 WAQ to extract a substring from 89
‘Quadratically’ which should be 6
character long and should start from
5th character
19 Find remainder of 11 / 4 and display 90
3^2
20 Truncate value of 15.79 to 1 decimal 91
place
21 WAQ to display Current date 92

22 WAQ to display date 10 days after 93


current date
23 WAQ to extract date from ‘2012-12- 94
31 01:02:03’
24 WAQ to display current date and 95
time

S.No TOPIC PAGE


NO.
1. Write a program that displays first three rows fetched from 96
student table of MySQL database ‘practical’
2. Write a program that displays all records fetched from 97
student table of MySQL database ‘practical’
3. Write a program to delete the record of student on the basis 98
of name entered at run time from ‘student’ table
4. Write a program to insert multiple records in ‘student’ table 99
5. Write a program to update the marks of roll no 5 to 87 in a 100
student table of MySQL
Q.1 Write a program to calculate simple interest using a function ‘interest’.
Specify default values as 10% rate of interest and 2 years of time period.
INPUT

OUTPUT
Q.2 Write a function to check weather a number is perfect or not.
INPUT

OUTPUT
Q.3 Write a function to reverse a string.
INPUT

OUTPUT
Q.4 Write a function to find square root of a number.
INPUT

OUTPUT
Q.5 Write a function to return sum of multiple numbers.
INPUT

OUTPUT
Q.6 Write a function to return sum of 3 numbers.
INPUT

OUTPUT
Q.7 Write a random number generator that generates random number
between 1 and 6. (Simulate a dice)
INPUT

OUTPUT
Q.8 Write a function that takes a positive integer and returns the one’s
position digit of integer.
INPUT

OUTPUT
Q.9 Write a recursive code to find the factorial of a number.
INPUT

OUTPUT
Q.10 Write a function to perform binary search in sorted list.
INPUT

OUTPUT
Q.11 Write a program using a recursive function to print Fibonacci series till n
terms.
INPUT

OUTPUT
Q.12 Write a program to perform insert and delete operation on a queue
containing member details as member number, member name and member
age.
INPUT

OUTPUT
Q.13 Write a program to implement stack of book details, each of details
contain book name and book number. Implement PUSH, POP and DISPLAY
operation.
INPUT

OUTPUT
Q.14 Write a program to sort list using bubble sort.

INPUT

OUTPUT
Q.15 Write a program to sort using insertion sort.
INPUT

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

OUTPUT
Q.17 Write a program to read text file and display the count of vowels and
consonants in the file.
INPUT

OUTPUT
Q.18 Write a program to get roll numbers, names and marks of students of a
class and store these details in a file called marks.txt.
INPUT

OUTPUT
Q.19 Consider the binary file Student.dat containing student detail. Write a
program to update the records of a file so that those who scored more than
81 get additional bonus marks of 2.
INPUT

OUTPUT
Q.20 Write to program to open a binary file and search for records with roll
number 12 or 14.
INPUT

OUTPUT
Q.21 Write a program to get item details (code, description and price) for
multiple items from the user and create a csv file by writing all the item
details in one go.
INPUT

OUTPUT
Q.22 Write a program to display the number of lines in a file.
INPUT

OUTPUT
TABLES
QUESTION
PRACTICAL 1
TABLE- STUDENT

1.1Write a query to display to display name, roll number and aggregate


divided by 5. Name column aggregate divided by 5 as percentage.

1.2 Write a query that produces result as student name, aggregate and age.
PRACTICAL 2
TABLE- STUDENT MARKS

Q.2 Write a query to display name, age and marks of students whose age is
greater than or equal to 16.
PRACTICAL 3
TABLE

3.1 Write a query that display all the details from the pet table from species
cat or dog and gender as male.
PRACTICAL 4
4.1 Display all records from table EMPL.

4.2 Display Emp No and Ename of all employees.

4.3 Display Ename, Sal and Sal added with Comm.


4.4 Write a query to display Ename, Salary and Department Number who are
not getting commission from table EMPL.

4.5 Write a query to display Employee Number, Name , sal and sal*12as
Annual Salary whose commission is not NULL from table EMPL.

4.6 List all department number is table EMPL.

4.7 List all unique Department Number in table EMPL.


4.8 List details of all clerks who have not been assigned department as yet.

4.9 List the details of all those employees who have four lettered name.

4.10 List the detail of all employees whose annual salary is between 25000-
40000.

4.11 How many job types are offered to the employees?


4.12 List the details of employees who earn more commission than their
salaries.

4.13 Write a query to display the name, job and salary of employees who do
not have manager.

4.14 Write a query to display the name of employee whose name contain ‘A’
as third alphabet.

4.15 Write a query to display the name of employee whose name contains ‘T’
as last alphabet.

4.16 Write a query to display the name of the employee who is having ‘L’ as
any alphabet of the name.

PRACTICAL 5
TABLE- SPORTS
5.1 Display name of the students who have grade ‘C’ in either Game1 or
Game2 or both.

5.2 Display the name of student who have same game for both Game1 and
Game2.

5.3 Display the game taken up by students whose name starts with ‘A’.

PRACTICAL 6
TABLE- STUDENT
6.1 Display Minimum Marks from Student where AVGMARK<75.

6.2 Display sum of stipend where grade is ‘B’.

6.3 Display Average of stipend where class is ‘12A’.


6.4 Display number of fields.
PRACTICAL 7
7.1 Create table.

7.2 For record with ID=4 update record with Last_Name,User_ID and Salary.

7.3 Display number of fields.

7.4 Modify the last name of employee 3 to Gautam.

7.5 Modify salary and increase it by 1000, for all who get salary less than
5000.
7.6 Delete employee having first name ‘Siddharth’.

7.7 Remove entire content of the table.


PRACTICAL 8
TABLE- STUDENT

8.1 Display the records in alphabetical order as per the name of the student.

8.2 Display class ,DOB and city whose marks is between 450 and 551.
8.3 Display name, class and total number of students who have secured more
than 450 marks class wise.

8.4 Increase marks of all students by 20 whose class is ‘XII’.


PRACTICAL 9
TABLE- STUDENT RELATION

9.1 Show all information about the students in History department.

9.2 List the name of female students who are in Hindi department.

9.3 List name of all students with their date of admission in ascending order.
9.4 Display student’s Name, fee age for male students only.

9.5 Count the number of Student with age<23.

9.6 Insert a new row in the table.


PRACTICAL 10
TABLE- DEPT

TABLE- WORKER

10.1 Display Wno, Name, Gender from the table WORKER in descending
order of Wno.
10.2 Display the name of all the female workers from the table WORKER.

10.3 Display the WNO and Name of those workers from the WORKER table
who are born between ‘1987-01-01’ and ‘1991-12-01’.

10.4 Count and display MALE workers who have joined after ‘1986-01-01’.

10.5 Count number of workers in more than one dept, dept wise.
10.6 Display number of distinct dept from dept table.

10.7 Display name, department and city of workers with WNO<1003 and
dcode common in workers and dept table.

10.8 To display max DOJ and min DOB from worker.


PRACTICAL 11
TABLE- STUDENT DATA

11.1 Display information of student in class ’11-B’.

11.2 Display 11 and 12 class student information.

11.3 Display student’s information who are not in 10th.


11.4 Display total fees paid.

11.5 Display average of total fees paid.

11.6 Display max fees.

11.7 Display min fees.

11.8 Display total number of students.


PRACTICAL 12
TABLE- EMPLOYEE 2

12.1 Add primary key constraint to ID column.

12.2 Add foreign key constraint that ensures record with invalid departments
are prohibited.

12.3 Add not constraint to EMPNAME.

12.4 Drop the table.


PRACTICAL 13
TABLE- CUSTOMER

13.1 Add one column Email Varchar (30).

13.2 Change data type of column PINCODE to Varchar (10).


PRACTICAL 14
Display 4 characters extracted from 3 left
character onwards from string ‘ABCDEFG’.
PRACTICAL 15

Display first three characters extracted from


jobs of employees 8888 and 8900.
PRACTICAL 16

Write a query to remove leading and trailing


spaces from string ‘Bar One’.
PRACTICAL 17
How many characters are there in
‘CANDIDE’.
PRACTICAL 18
Write a query to extract a substring from
‘Quadratically’ which should be 6 character
long and should start from 5th character.
PRACTICAL 19
Find remainder of 11/4 and display 3^4.
PRACTICAL 20
Truncate value of 15.79 to one decimal
place.
PRACTICAL 21
Write a query to display current date.
PRACTICAL 22
Write a query to display date, 10 days after
current date.
PRACTICAL 23
Write a query to extract date from ‘2012-12-
31 01:02:03’.
PRACTICAL 24
Write a query to display current date and
time.
Q.25 Write a program that displays first three rows fetched from “Student”
table of MySQL practical.
INPUT

OUTPUT
Q.26 Write a program that displays all records fetched from “Student” table
of MySQL database practical.
INPUT

OUTPUT
Q.27 Write a program to delete the record of student on the basis of name
entered at run time from “Student” table.
INPUT

OUTPUT
Q.28 Write a program to inset multiple records in “Student” table.
INPUT

OUTPUT

Q.29 Write a program to update the marks of roll number 8 to 57 in MySQL.


INPUT

OUTPUT

You might also like