0% found this document useful (0 votes)
21 views50 pages

Practical FIle

Uploaded by

kushan4589
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)
21 views50 pages

Practical FIle

Uploaded by

kushan4589
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/ 50

SALWAN PUBLIC SCHOOL

MAYUR VIHAR PHASE-III

COMPUTER SCIENCE (083)


PRACTICAL FILE

SESSION :

NAME :
CLASS :

BOARD ROLL NO :
2
INDEX
S NO. PROGRAMMES PAGE NO.
1. WAP to modify the employee record with the 10
following dictionary structure:
{“Empno”:1234, ”Name”:”ABC”,
“Salary”:4000, ”Desig”: ”President”}
2. WAP to modify the employee record with the 11
following dictionary structure: {1234:
{”Name”: ”ABC”, “Salary”: 4000, ”Desig”:
”President”}}
3. Append the employee records in the above 12
binary file.
4 WAP using function to check whether the 13
passed number is a perfect number or not.
Return true or false. Example 6: 1+2+3 (Sum
of all positive divisors)
5. Write a function that prints the first n rows of 14
Pascal’s triangle.
6. Write a function that takes amount-in-dollars 14
and dollar-to-rupee conversion price; it then
returns the amount converted to rupees.
Create the function in both void and non-void
forms.

7. Write a function to calculate the volume of a 15


box with appropriate default values for its
parameters. Your function should have the
following input parameters:
a. length of box
b. width of box

3
c. height of box.
Test it by writing a complete program to
invoke it.

8. Write a function that receives two numbers 15


and generates a random number from that
range. Using this function, the main program
should be able to print three numbers
randomly.

9. Write a function that receives two string 16


arguments and check whether they are same-
length strings
a. (returns True in this case otherwise false).

10. WAP using a function to return the number of 17


lowercase and uppercase alphabets of the
passed string.

11. WAP to make a function which accepts a 17


number n and returns a randomly generated
number having exactly n digits.

12. WAP in Python to read the first 5 characters in 17


a string and display. Again read the next 4
characters in the same string and display. The
name of the Text File is abc.txt

13. WAP in Python to read first 3 lines of text, 18


from the text file abc.txt

14. WAP in python to read and display all those 18


lines which start with ‘T’.

15. WAP in python to calculate number of spaces 19


in the file abc.txt

16. WAP to read a text file line by line and display 19

4
each word separated by a ‘#’.

17. WAP in python to calculate number of vowels 20


in the file abc.txt

18. WAP in program to calculate number of words 20


‘to’ in the file abc1.txt

19. WAP to read the content of the file and 21


display ‘T’ in place of ‘E’ while displaying the
content of the file, all other characters should
appear as it is.

20. WAP to read the content of the file and 21


display how many uppercase characters and
digits are present.

21. Write a function ISTOUPCOUNT() in python to 21


read the content of file WRITER.TXT, to count
and display the occurrence of IS and UP.

22. Write a Program in Python to create a text file 22


(myfile.txt) containing strings (input by user)
as many times as the user types ‘y’ (yes).

23. Write a program to create a text file which 23


should have names of your 10 friends in 10
lines (friends.txt)

24. Write a Program in Python to create two text 24


files (file1.txt, file2.txt) containing names of
students (from friends.txt) according to
following:
a. file1.txt contains the name of students
starting with ‘A’ to ‘M’
b. file2.txt contains the name of students
starting with ‘N’ to ‘Z’

5
25. WAP to copy only those lines from abc.txt 24
which start with ‘T’ to dup.txt

26. Create a module sphere and have multiple 25


functions of calculating volume of solid
sphere, surface area of solid sphere, volume
of hollow sphere and surface area of hollow
sphere.

27. WAP uses a function to generate a 6-digit 25


passcode/pin to be used as OTP.

28. WAP using UDF to generate 3 random 26


integers between 100 and 999 which are
divisible by 5

29. WAP to generate a random Password which 26


meets the following conditions:
Password length must be 10 characters long.
It must contain at least 2 uppercase letters, 1
digit, and 1 special symbol.

30. WAP to display the following menu using UDFs 27


:
1. Write new records in employee.csv
2. Read the data in employee.csv
3. Backup of employee.csv in backup.csv

31. Write a menu-driven python program to 29


implement stack operation.
32. Write a program to implement a stack for the 31
employee details in tuple (empno, name) as
an element of the stack.
33. Write a python program to check whether a 34
string is a palindrome or not using stack.

6
34 Write a MySQL connectivity program in 35
Python to connect the given database and
table

a. Create a database Employee in MySQL

b. Create a table emp with the specifications


in MySQL:
● EMPNO integer
● ENAME character(10)
● SAL

After connecting, perform the following


operations:
1. Insert records through Python.
2. Display all the records.
3. Update the salary of the employee.
4. Delete an employee from the database.

35. Observe the following table : 38

A. Display the type of movies.


B. Display movie id, movie name, total
earning by showing the business done by
the movies. Calculate the business done
by movie using the sum of production
cost and business cost.

7
C. Display movie id, movie name and
production cost for all movies with
production cost greater than 150000 and
less than 1000000.
D. Display the movie of type action and
romance.
E. Display the list of movies which are
going to release in February, 2022.

36. Queries based on functions : 40

A. Write a query to display cube of 5.


B. Write a query to display the number
563.854741 rounding off to the next
hundred.
C. Write a query to display “put” from the
word “Computer”.
D. Write a query to display today’s date into
DD.MM.YYYY format.
E. Write a query to display ‘DIA’ from the
word “MEDIA”.
F. Write a query to display movie name –
type from the table movie.
G. Write a query to display first four digits
of production cost.
H. Write a query to display last four digits of
business cost.
I. Write a query to display weekday of
release dates.
J. Write a query to display day name on
which movies are going to be released.

37. DDL Commands : 42


a. Create a database “Sports”.

8
b. Create a table “TEAM” with following
considerations:
● TeamID for storing an integer value
between 1 to 9, which refers to unique
identification of a team.
● TeamName which should be a string of
length not less than 10 characters.

c. Using table level constraint, make TeamID


as the primary key.
d. Show the structure of the table TEAM using
a SQL statement.
e. As per the preferences of the students four
teams were formed as given below. Insert
these four rows in TEAM table:
● Row 1: (1, Challengers)
● Row 2: (2, Motivators)
● Row 3: (3, Warriors)
● Row 3: (4, Innovators)
f. Show the contents of the table TEAM using
a DML statement.
g. Now create another table MATCH_DETAILS
and insert data as shown below. Choose
appropriate data types and constraints for
each attribute :

9
38. Queries (Based on Two Tables) 44

A. Display the match id, team id, team


score who scored more than 70 in the
first innings along with team name.
B. Display match id, team name and
second team score between 100 to 160.
C. Display match id, team names along
with match dates.
D. Display unique team names
E. Display match id and match date played
by Challengers and Motivators

39. Queries (Group by , Order By) 45


Consider the following table stock table to
answer the queries:

A. Display all the items in the ascending


order of stock date.

10
B. Display maximum price of items for each
dealer individually as per dcode from
stock.
C. Display all the items in descending
orders of item names.
D. Display average price of items for each
dealer individually as per dcode from
stock which average price is more than
5.
E. Display the sum of quantity for each
dcode.

TERM-I

1. WAP to modify the employee record with the


following dictionary structure:
{“Empno”:1234, ”Name”:”ABC”, “Salary”:4000,
”Desig”:”President”}

11
Output

12
2. WAP to modify the employee record with the
following dictionary structure: {1234:
{”Name”:”ABC”,“Salary”:4000,”Desig”:”President”}
}

13
Output

14
3. Append the employee records in the above binary
file.

Output

15
4. WAP using function to check whether the passed
number is a perfect number or not. Return true or
false. Example 6: 1+2+3 (Sum of all positive divisors)

Output

5. Write a function that prints the first n rows of


Pascal’s triangle.

16
Output

6. Write a function that takes amount-in-dollars and


dollar-to-rupee conversion price; it then returns the
amount converted to rupees. Create the function in
both void and non-void forms.

17
Output

7. Write a function to calculate the volume of a box with


appropriate default values for its parameters. Your
function should have the following input parameters:
a. length of box
b. width of box
c. height of box.

Output

8. Write a function that receives two numbers and


generates a random number from that range. Using
this function, the main program should be able to
print three numbers randomly.

18
Output

9. Write a function that receives two string arguments


and check whether they are same-length strings
a. (returns True in this case otherwise False).

Output

10 WAP using a function to return the number of

19
. lowercase and uppercase alphabets of the passed
string.

Output

11 WAP to make a function which accepts a number n


. and returns a randomly generated number having
exactly n digits.

Output

12 WAP in Python to read the first 5 characters in a


. string and display. Again read the next 4 characters
in the same string and display. The name of the Text
File is abc.txt

20
Output

13 WAP in Python to read first 3 lines of text, from the


. text file abc.txt

Output

14 WAP to read and display all those lines which start


. with ‘T’.

21
Output

15 WAP in python to calculate number of spaces in the


. file abc.txt

Output

16 WAP to read a text file line by line and display each


. word separated by a ‘#’.

Output

22
17 WAP in python to calculate number of vowels in the
. file abc.txt

Output

18 WAP in program to calculate number of words ‘to’ in


. the file abc1.txt

Output

19 WAP to read the content of the file and display ‘T’ in


. place of ‘E’ while displaying the content of the file,

23
all other characters should appear as it is.

Output

20 WAP to read the content of the file and display how


. many uppercase characters and digits are present.

Output

21 Write a function ISTOUPCOUNT() in python to read


. the content of file WRITER.TXT, to count and display
the occurrence of IS and UP.

24
Output

22 Write a Program in Python to create a text file


. (myfile.txt) containing strings (input by user) as
many times as the user types ‘y’ (yes).

25
Output

23 Write a program to create a text file which should


. have names of your 10 friends in 10 lines
(friends.txt)

Output

24 Write a Program in Python to create two text files


. (file1.txt, file2.txt) containing names of students
(from friends.txt) according to following:

26
a. file1.txt contains the name of students starting
with ‘A’ to ‘M’
b. file2.txt contains the name of students starting
with ‘N’ to ‘Z’

Output

25 WAP to copy only those lines from abc.txt which start


. with ‘T’ to dup.txt

27
Output

26 Create a module sphere and have multiple functions


. of calculating volume of solid sphere, surface area of
solid sphere, volume of hollow sphere and surface
area of hollow sphere.

27 WAP uses a function to generate a 6-digit


. passcode/pin to be used as OTP.

28
Output

28 WAP using UDF to generate 3 random integers


. between 100 and 999 which are divisible by 5

Output

29 WAP to generate a random Password which meets


. the following conditions:
Password length must be 10 characters long.
It must contain at least 2 uppercase letters, 1 digit,
and 1 special symbol.

29
Output

30 WAP to display the following menu using UDFs :


. 1. Write new records in employee.csv
2. Read the data in employee.csv
3. Backup of employee.csv in backup.csv

30
Output

31
TERM-II

31 Write a menu-driven python program to implement


. stack operation.

32
Output

33
32 Write a program to implement a stack for the
. employee details in tuple (empno, name) as an
element of the stack.

34
Output

35
36
33 Write a python program to check whether a string is
. a palindrome or not using stack.

Output

37
34 Write a MySQL connectivity program in Python to
. connect the given database and table

a. Create a database Employee in MySQL

b. Create a table emp with the specifications in


MySQL:
● EMPNO integer
● ENAME character(10)
● SAL

After connecting, perform the following operations:


1. Insert records through Python.
2. Display all the records.
3. Update the salary of the employee.
4. Delete an employee from the database.

38
Output

39
40
35 Observe the following table :
.

A. Display the type of movies.


B. Display movie id, movie name, total earning by
showing the business done by the movies.
Calculate the business done by movie using the
sum of production cost and business cost.
C. Display movie id, movie name and production
cost for all movies with production cost greater
than 150000 and less than 1000000.
D.Display the movie of type action and romance.

41
E. Display the list of movies which are going to
release in February, 2022.

A.

B.

C.

D.

E.

42
36 Queries based on functions :
.
A. Write a query to display cube of 5.
B. Write a query to display the number 563.854741
rounding off to the next hundred.
C. Write a query to display “put” from the word
“Computer”.
D.Write a query to display today’s date into
DD.MM.YYYY format.
E. Write a query to display ‘DIA’ from the word
“MEDIA”.
F. Write a query to display movie name – type from
the table movie.
G.Write a query to display first four digits of
production cost.
H.Write a query to display last four digits of
business cost.
I. Write a query to display weekday of release
dates.
J. Write a query to display day name on which
movies are going to be released.

A. B
B.

43
C.
B D.

E. BF.

G.
B H.

I. BJ.

37 DDL Commands :

44
.
a. Create a database “Sports”.
b. Create a table “TEAM” with following
considerations:
● TeamID for storing an integer value between 1
to 9, which refers to unique identification of a
team.
● TeamName which should be a string of length
not less than 10 characters.

c. Using table level constraint, make TeamID as the


primary key.
d. Show the structure of the table TEAM using a SQL
statement.
e. As per the preferences of the students four teams
were formed as given below. Insert these four rows
in TEAM table:
● Row 1: (1, Challengers)
● Row 2: (2, Motivators)
● Row 3: (3, Warriors)
● Row 3: (4, Innovators)
f. Show the contents of the table TEAM using a DML
statement.
g. Now create another table MATCH_DETAILS and
insert data as shown below. Choose appropriate data
types and constraints for each attribute :

45
a.

b.
c.

d.

e.

f.

46
g.

38 Queries (Based on Two Tables)


.
A. Display the match id, team id, team score who
scored more than 70 in the first innings along
with team name.
B. Display match id, team name and second team
score between 100 to 160.
C. Display match id, team names along with match
dates.
D.Display unique team names
E. Display match id and match date played by
Challengers and Motivators

A.

47
B.

C.

D.

E.

48
39 Queries (Group by , Order By)
. Consider the following table stock table to answer
the queries:

A. Display all the items in the ascending order of


stock date.
B. Display maximum price of items for each dealer
individually as per dcode from stock.
C. Display all the items in descending orders of
item names.
D.Display average price of items for each dealer
individually as per dcode from stock which
average price is more than 5.
E. Display the sum of quantity for each dcode.

A.

49
B.

C.

D.

E.

50

You might also like