0% found this document useful (0 votes)
14 views35 pages

Practicals

Uploaded by

rishabhsingh8552
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views35 pages

Practicals

Uploaded by

rishabhsingh8552
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 35

r. Sec.

Public
S Sc
P.

ho
R. R.

ol
Kanpur Road, Fatehgarh
Session: 2024-25
Class: XII
Subject: Computer Science (083)

Practical File
Submitted to: Submitted by:
Name:_____________
RollNo:_____________

Teacher’s Signature Principal’s Signature Examiner’s Signature


Index
Experiment
Practical based problems
No
Write a program that multiplies two integer numbers without using * operator, using
1.
repeated addition.
Write a python program that reads a line and prints its statistics like.
➢ Number of uppercase letters
2. ➢ Number of lowercase letters
➢ Number of alphabets
➢ Number of digits
3. Write a program that prints the second largest number from a list of numbers.
4. Write a python program that creates a tuple storing first 9 terms of Fibonacci series.
Create a dictionary whose keys are month names and whose values are the numbers
of days in the corresponding months.
(a) Ask user to enter a month name and use the dictionary to tell them how
5. many days are in the month.
(b) Print out all of keys in alphabetical order.
(c) Print out all of the months with 31 days.
(d) Print out the (Key-value) pairs sorted by number of days in each month.
Program that receives two numbers in a function and returns the result of all
6. arithmetic operations (+,-,*,/,%) on these numbers.

Write a function that receives a decimal number and prints the equivalent number
7.
in binary.
Write a function that receives two numbers and generates a random number from
8. that range. Using this function, the main program should be able to print three
numbers randomly.
Write a program that generates a series using a function which takes first and last
9. values of the series and then generates four terms that are equidistant e.g., if two
numbers passed are 1 and 7 then function return 1 3 5 7.
Write a Program to enter the number and print the Floyd’s Triangle in decreasing
10.
order.
11. Write a program to count the words “to” and “the” present in a text file “Poem.txt”.
Write a program to get roll numbers, names and marks of the students of a class
12.
(get from user) and store these details in a file called “Marks.txt”.
A binary file “Book.dat” has structure [BookNo,Book_Name,Author,Price].
1. Write a user defined function CreateFile() to input data for a record
and add to book .dat
13. 2. Write a function CountRec(Author) in python which accepts the
author name as parameters and count and return number of books
by the given Author are stored in the binary file “Book.dat”.

A CSV file “StuRecord.csv” has structure Rollno, StuName, Class, Marks.


Write a user defined functions for the followings.
 Updating data.
14.
 Searching Specific Record.
 Displaying All records of specific file.
Program 14: Python program to implement stack operations.
15.
Operations are: 1-Push(), 2-Pop() , 3-Peek(),4-Display()
16. MySQL Database problems
17. Write a python-Mysql interface program for creating a table in MySQL.
18. Write a python-Mysql interface program for inserting data into table of MySQL.
Write a python-Mysql interface program for searching a specific record in a table of
19.
MySQL
Write a python-Mysql interface program for updating a specific record in a table of
20.
MySQL.
Date : 11/May/2024 Experiment No: 1

Program 1: Write a program that multiplies two integer numbers without using * operator, using
repeated addition.
Solution:

Output :
Date : 04/July/2024 Experiment No: 2

Program 2: Write a python program that reads a line and prints its statistics like.
➢ Number of uppercase letters
➢ Number of lowercase letters
➢ Number of alphabets
➢ Number of digits
Solution:

Output:
Date : 08/July/2024 Experiment No: 3

Program 3: Write a program that prints the second largest number from a list of numbers.
Solution:

Output:
Date : 12/July/2024 Experiment No: 4

Program 4: Write a python program that creates a tuple storing first 9 terms of Fibonacci series.
Solution:

Output:
Date : 19/July/2024 Experiment No: 5

Program 5: Create a dictionary whose keys are month names and whose values are the numbers of
days in the corresponding months.
a) Ask user to enter a month name and use the dictionary to tell them how many days
are in the month.
b) Print out all of keys in alphabetical order.
c) Print out all of the months with 31 days.
d) Print out the (Key-value) pairs sorted by number of days in each month.
Solution : a

Output :

Solution : b

Output :

Continue……
Solution : c

Output :

Solution : d

Continue…….
Output :
Date : 21/August/2024 Experiment No: 6

Program 6: Program that receives two numbers in a function and returns the result of all arithmetic
operations (+,-,*,/,%) on these numbers.
Solution :

Output :
Date : 28/August/2024 Experiment No: 7

Program 7: Write a function that receives a decimal number and prints the equivalent number in
binary.
Solution :

Output :
Date : 31/August/2024 Experiment No: 8

Program 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.
Solution:

Output :
Date : 09/September/2024 Experiment No: 9
Program 9: Write a program that generates a series using a function which takes first and last
values of the series and then generates four terms that are equidistant e.g., if two
numbers passed are 1 and 7 then function return 1 3 5 7.
Solution:

Output:
Date:10/September/2024 Experiment No:10

Program 10 : Write a Program to enter the number and print the Floyd’s Triangle in decreasing
order.
Date : 14/October/2024 Experiment No: 11

Program 11: Write a program to count the words “to” and “the” present in a text file “Poem.txt”.
Solution:

Output:
Date : 21/October/2024 Experiment No: 12

Program 12: Write a program to get roll numbers, names and marks of the students of a class (get
from user) and store these details in a file called “Marks.txt”.
Solution:

Output & Text File:


Date : 25/October/2024 Experiment No: 13

Program 13: A binary file “Book.dat” has structure [BookNo,Book_Name,Author,Price].


3. Write a user defined function CreateFile() to input data for a record and add to book
.dat
4. Write a function CountRec(Author) in python which accepts the author name as
parameters and count and return number of books by the given Author are stored in
the binary file “Book.dat”.

Solution:
Output:
Date : 16/November/2024 Experiment No: 14

Program 14: A CSV file “StuRecord.csv” has structure Rollno, StuName, Class, Marks.
Write a user defined functions for the followings.
 Updating data.
 Searching Specific Record.
 Displaying All records of specific file.
output:
Date : 14/December/2024 Experiment No: 15

Program 15: Python program to implement stack operations.


Operations are:
1-Push()
2-Pop()
3-Peek()
4-Display()
Solution:

Continue…..
Output:

Output:
Date : 16/December/2024 Experiment No: 16

In a Database, there are two tables given below:

Table: Employee
Employ Nam Job
Sales
eeID e id
E1 Sumi 1100 10
t 000 2
Sinha
E2 Vijay 1300 10
Singh 000 1
Toma
r
E3 Ajay 1400 10
Rajpa 000 3
l
E4 Mohi 1250 10
t 000 2
Ram
nani
E5 Shailj 1450 10
a 000 3
Singh

Table: Job

JOBID JOBTITLE SALARY


101 President 200000
102 Vice President 125000
103 Administrator Assistant 80000
104 Accounting Manager 70000
105 Accountant 65000
106 Sales Manager 80000

Write SQL queries for the following:


a. To display employee ids, names of employee, job ids with corresponding job titles.
b. To display names of employees, sales and corresponding job titles who have achieved
sales more than 1300000.
c. To display names and corresponding job titles of those employees who have
“Singh”(anywhere) in their names.
d. Write SQL command to change the jobid to 104 of the EMPLOYEE with ID as E4 in the
table ‘EMPLOYEE’.
e. List the count of employees having “Manager” as “Job”.(table employee)
f. List the sum of employees’ salaries grouped by jobtitle. (table employee)
Solutions:
Commands for creating tables and inserting data:
Table : Employee

Table: Job

Solution a.

Solution b.
Solution c.

Solution d.

Solution e.

Solution f.
Date : 17/December/2024 Experiment No: 17

Program 17: Write a python-Mysql interface program for creating a table in MySQL.
Solution:

Output:
Date : 18/December/2024 Experiment No: 18

Program 18: Write a python-Mysql interface program for inserting data into table of MySQL.
Solution:

Output:
Date : 19/December/2024 Experiment No: 19

Program 19: Write a python-Mysql interface program for searching a specific record in a table of
MySQL.
Solution:

Output:
Date : 19/December/2024 Experiment No: 20

Program 20: Write a python-Mysql interface program for updating a specific record in a table of
MySQL.
Solution:
Continue…..
Output:

You might also like