0% found this document useful (0 votes)
26 views

Practical 12 File-1

Uploaded by

Gauransh Narang
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)
26 views

Practical 12 File-1

Uploaded by

Gauransh Narang
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/ 38

THE SOVEREIGN SCHOOL

PRACTICAL FILE
COMPUTER SCIENCE
2024-25

SUBMITTED BY: - SUBMITTED TO:-


________________
ROLL NO.:- SHWETA MITTAL
CLASS: -

INDEX
S. SIGNATU
NO NAME OF THE PROGRAM RE
1 Write a python function to compute the area of rectangle. Function
should return a value
2 Write a python function to calculate factorial of a given number.
3 Write a python function to add and subtract two values and return
the calculated result.
4 Write a python function to compute the basic calculation
performed by a calculator.
5 Write a python function to calculate the sum and product of first 10
natural numbers.
6 Write a python function with name “compute_volume” which will
perform the following function:
 It will ask the user to input diameter of a sphere.
 Calculate the volume of sphere.
 Print the statement which will display with a proper
message of volume of sphere.
 Function should return a value.
7 Write a python menu driven function to compute basic calculation
performed by a calculator.
8 Write a python function to accept a string as an input and to count
and display the total number of vowels present in it.
9 Write a python function to accept string as an input and to count
and display the total number of times a character is present.
10 Write a program to input elements in a tuple and to count and
display number of even and odd numbers present in it using
function.
11 Write a program to pass a dictionary to a function with list of
elements as keys and frequency of its occurrence as value and
return as a dictionary.
12 Write a program to read all lines from the file into list.
13 Write a program to copy the contents of a file to another file.
14 A text file named “test_report.txt” exists on a disk with the
following content [lines].
Write a function capitalize_Sentence() to create a copy of file
"test_report.txt" named as "file1.txt", which should convert the
first letter of the file and the first alphabetic character following a
full stop into upper case.
15 Write a program to store and display multiple integers in and from
a binary file.

16 Write a program to insert/append a record in the binary file


"student.dat".
17 Write a program to read a record from the binary file
"student.dat"
18 Write a program to search a record from the binary file
"student.dat" on the basis of roll number.
19 Write a program to read the contents of “student.csv” file using
with open().
20 Write a program to count the number of records present in
“student.csv” file.
21 Consider a database LOANS. Answer the following questions:
i. Display the sum of all loan amounts whose interest rate is
greater than 10.
ii. Display the maximum interest from loans table.
iii. Display the count of all loan holders whose name ends with
‘Sharma’.
iv. Display the count of all loan holders whose interest rate is
Null.
v. Display the interest-wise details of loan account holders.
vi. Display the interest-wise details of loan account holders with
at least 10 instalments remaining.
22 Consider the following tables Product and Client. Write SQL
commands for the statements (i) to (iii) and give outputs for SQL
queries (iv) to (vi).
i. To display the details of those clients whose city is Delhi.
ii. To display the details of products whose price is in range of
50 to 100(both values included).
iii. To display the details of those products whose name ends
with ‘Wash’.
iv. SELECT DISTINCT CITY FROM CLIENT;
v. SELECT MANUFACTURER, MAX(PRICE),MIN(PRICE),
COUNT (*) FROM PRODUCT GROUP BY
MANUFACTURER;
vi. SELECT PRODUCT NAME, PRICE*4 FROM PRODUCT;
23 Consider the following two tables: PRODUCT and CLIENT
NOTE: in product P_ID is primary key. In client C_ID is primary
key and P_ID is the foreign key referencing P_ID of client table.
Write SQL commands for the queries (i) to (iv) and output for (v)
and (vi):
i. To display the client name and city of all Mumbai and Delhi
based clients in client table.
ii. Increase the price of all products in product table by 10%.
iii. To display the product name, manufacturer, expiry date of
all the products that expired on or before ‘2010-12-31’.
iv. To display C_ID, client name, city of all the clients
(including the ones who have not purchased a product) and
their corresponding product name sold.
v. SELECT COUNT(DISTINCT MANUFACTURER)FROM
PRODUCT;
vi. SELECT C_ID, CLIENT_NAME, CITY FROM CLIENT
WHERE CITY LIKE ‘M%’;
24 Consider the following two tables: stationary and consumer.
NOTE: in stationary S_ID is primary key. In consumer C_ID is the
primary key and P_ID is the foreign key referencing S_ID of
stationary table.
Write SQL commands for the queries (i) to (iv) and output for (v)
to (vi):
i. To display details of all the stationary items in the stationary
table in descending order of stock date.
ii. To display details of that stationary item whose company is
xyz and price is below 10.
iii. To display consumer name, address from the table consumer
and company and price from stationary table, with their
corresponding S_ID.
iv. To increase the price of all the stationary table by rupees2.
v. SELECT COUNT(DISTINCT ADDRESS) FROM
CONSUMER;
vi. SELECT STATIONARY_NAME, PRICE*3 FROM
STATIONARY WHERE COMPANY=’CAM’;
25 Consider the table employee and salgrade and answer (a) and (b)
parts of the question:
a) Write sql commands for the following statements:
i. To display the details of all employees in descending
order of DOJ.
ii. To display name and desig of those employees whose
salgrade is either S02 OR S03.
iii. To display the content of the entire employees table,
whose DOJ is in between ’09-Feb-2006’ and ’08-Aug-
1983’.
iv. To add a new row with the following content;
109,’Harish Roy’,’HEAD-IT’,’S02’,’9-Sep-2007’,’21-
Apr-1983’
b) Give the output of the following SQL queries:
i. SELECT COUNT(SGRADE), SGRADE FROM
EMPLOYEE GROUP BY SGRADE;
ii. SELECT MIN(DOB), MAX(DOJ) FROM
EMPLOYEE;
iii. SELECT SGRADE, SALARY+HRA FROM
SALGRADE WHERE SGRADE=’S02’;
26 Write a Python programme to implement all basic operations of a
stack, such as adding element(PUSH operation), removing element
(POP operation) and displaying the stack elements(TRAVERSAL
operation)using lists.
27 Write a programme to display unique vowels present in the given
word using stack.
28 Write a program to create a stack called Employee, to perform the
basic operations on stack using list. The list contains the two values-
employee number and employee name. The program should include
the options for addition, deletion and display of employee details.
QUES-1: Write a python function to compute the area of rectangle. Function should
return a value
QUES-2: Write a python function to calculate factorial of a given number.
QUES-3: Write a python function to add and subtract two values and return the calculated
result.
QUES-4: Write a python function to compute the basic calculation performed by a
calculator.
QUES-5: Write a python function to calculate the sum and product of first 10 natural
numbers.
QUES-6: Write a python function with name “compute_volume” which will perform the
following function:
 It will ask the user to input diameter of a sphere.
 Calculate the volume of sphere.
 Print the statement which will display with a proper message of volume of
sphere.
 Function should return a value.
QUES-7: Write a python menu driven function to compute basic calculation performed by
a calculator.
QUES-8: Write a python function to accept a string as an input and to count and display
the total number of vowels present in it.
QUES-9: Write a python function to accept string as an input and to count and display the
total number of times a character is present.
QUES-10: Write a program to input elements in a tuple and to count and display number
of even and odd numbers present in it using function.
QUES-11: Write a program to pass a dictionary to a function with list of elements as keys
and frequency of its occurrence as value and return as a dictionary
QUES-12: Write a program to read all lines from the file into list.
QUES-13: Write a program to copy the contents of a file to another file.
QUES-14: A text file named “test_report.txt” exists on a disk with the following content
[lines].

Write a function capitalize_Sentence() to create a copy of file "test_report.txt" named as


"file1.txt", which should convert the first letter of the file and the first alphabetic character
following a full stop into upper case.
QUES-15: Write a program to store and display multiple integers in and from a binary
file.
QUES-16: Write a program to insert/append a record in the binary file "student.dat".
QUES-17: Write a program to read a record from the binary file "student.dat"
QUES-18: Write a program to search a record from the binary file "student.dat" on the
basis of roll number.
QUES-19: Write a program to read the contents of “student.csv” file using with open().
QUES-20: Write a program to count the number of records present in “student.csv” file.
QUES-21: Consider a database LOANS. Answer the following questions:

i. Display the sum of all loan amounts whose interest rate is greater than 10.
ii. Display the maximum interest from loans table.
iii. Display the count of all loan holders whose name ends with ‘Sharma’.
iv. Display the count of all loan holders whose interest rate is Null.
v. Display the interest-wise details of loan account holders.
vi. Display the interest-wise details of loan account holders with at least 10 instalments
remaining

i)

ii)

iii)
iv)

v)

vi)
QUES-22: Consider the following tables Product and Client. Write SQL commands for the
statements (i) to (iii) and give outputs for SQL queries (iv) to (vi).
i. To display the details of those clients whose city is Delhi.
ii. To display the details of products whose price is in range of 50 to 100(both values
included).
iii. To display the details of those products whose name ends with ‘Wash’.
iv. SELECT DISTINCT CITY FROM CLIENT;
v. SELECT MANUFACTURER, MAX(PRICE),MIN(PRICE), COUNT (*) FROM
PRODUCT GROUP BY MANUFACTURER;
vi. SELECT PRODUCT NAME, PRICE*4 FROM PRODUCT;

i)

ii)
iii)

iv)

v)

vi)
QUES-23: Consider the following two tables: PRODUCT and CLIENT
NOTE: in product P_ID is primary key. In client C_ID is primary key and P_ID is the
foreign key referencing P_ID of client table. Write SQL commands for the queries (i) to
(iv) and output for (v) and (vi):
i. To display the client name and city of all Mumbai and Delhi based clients in client
table.
ii. Increase the price of all products in product table by 10%.
iii. To display the product name, manufacturer, expiry date of all the products that
expired on or before ‘2010-12-31’.
iv. To display C_ID, client name, city of all the clients (including the ones who have not
purchased a product) and their corresponding product name sold.
v. SELECT COUNT(DISTINCT MANUFACTURER)FROM PRODUCT;
vi. SELECT C_ID, CLIENT_NAME, CITY FROM CLIENT WHERE CITY LIKE
‘M%’;

i)
ii)

iii)

iv)

v)

vi)
QUES-24: Consider the following two tables: stationary and consumer.

NOTE: in stationary S_ID is primary key. In consumer C_ID is the primary key and P_ID
is the foreign key referencing S_ID of stationary table.

Write SQL commands for the queries (i) to (iv) and output for (v) to (vi):

i. To display details of all the stationary items in the stationary table in descending
order of stock date.
ii. To display details of that stationary item whose company is xyz and price is below
10.
iii. To display consumer name, address from the table consumer and company and
price from stationary table, with their corresponding S_ID.
iv. To increase the price of all the stationary table by rupees2.
v. SELECT COUNT(DISTINCT ADDRESS) FROM CONSUMER;
vi. SELECT STATIONARY_NAME, PRICE*3 FROM STATIONARY WHERE
COMPANY=’CAM’;

i)
ii)

iii)

iv)

v)

vi)
QUES-25: Consider the table employee and salgrade and answer (a) and (b) parts of the
question:

a) Write sql commands for the following statements:


v. To display the details of all employees in descending order of DOJ.
vi. To display name and desig of those employees whose salgrade is either S02
OR S03.
vii. To display the content of the entire employees table, whose DOJ is in
between ’09-Feb-2006’ and ’08-Aug-1983’.
viii. To add a new row with the following content;
109,’Harish Roy’,’HEAD-IT’,’S02’,’9-Sep-2007’,’21-Apr-1983’
b) Give the output of the following SQL queries:
iv. SELECT COUNT(SGRADE), SGRADE FROM EMPLOYEE GROUP BY
SGRADE;
v. SELECT MIN(DOB), MAX(DOJ) FROM EMPLOYEE;
vi. SELECT SGRADE, SALARY+HRA FROM SALGRADE WHERE
SGRADE=’S02’;

a)i)
ii)

iii)

iv)

b)i)

ii)

iii)
QUES-26: Write a Python programme to implement all basic operations of a stack, such as
adding element(PUSH operation), removing element (POP operation) and displaying the
stack elements(TRAVERSAL operation)using list:
QUES-27: Write a programme to display unique vowels present in the given word using
stack.
QUES-28: Write a program to create a stack called Employee, to perform the basic
operations on stack using list. The list contains the two values-employee number and
employee name. The program should include the options for addition, deletion and display
of employee details.

You might also like