Practicals
Practicals
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:_____________
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”.
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:
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
Continue…..
Output:
Output:
Date : 16/December/2024 Experiment No: 16
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
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: