Practical File

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 37

COMPUTER

ADITYA Soni
CRPFPS ROHINI

PRACTICAL FILE
2021-2022
Q`1:Write a menu driven program for the given options using separate functions for each menu option:-

1. To find factorial of a number.

2. To find roots of a quadratic equation

3. To reverse a given number

4. Exit
OUTP
UT:

Q2: Write a menu driven program for a given string using separate functions

for each menu option:-

1. To count number of alphabets, digits and special characters.

2. To count number of words

3. To check whether the string is a palindrome or not

4. Exit
CODING:

OUTPUT:-
Q3: Create a dictionary whose keys are month names and whose values are the number of days in the corresponding months.
Then run the given menu on

the dictionary.

1. Ask the user to enter a month name & use the dictionary to tell them how many days are in the month.

2. Print out all of the keys in alphabetical order.

3. Print out all of the months with 31 days.

4. Print out the (key – value) pairs sorted by the number of days in

each month.

5. Exit CODE:-
OUTPUT:-
Q4:Write a program using function called addict ( dict1, dict2) which computes the union of two
dictionaries. It should return a new dictionary , with all the items in both its arguments (assumed to be
dictionaries). If the same key appears in both arguments, then pick a value from either of the two
dictionaries.

CODING:-
OUTPUT:

Q5:Write a program using a list which contains roll. No., name and marks of the student. Sort the list in
descending order of marks using Selection Sort algorithm.

CODING:-
OUTPUT:-

Q6: Write a program using function that takes a sorted list and a number as an argument. Search for the
number in the sorted list using binary search.

CODING:
OUTPUT:-
Q7:Write a program which accept a list containing numbers. Sort the list using any sorting technique.
Thereafter accept a number and display the position where that number is found. Also display suitable
message, if the number is not found in the list.

CODING:-
OUTPUT:-
Q8:Write a program in Python to implement a stack

Coding:

Output:
Q9:Write a program in Python to implement a Queue

Coding:

Output:-
Q10:Write a program that takes any two lists L & M of the same size & adds their elements
together to form a new list N whose elements are sums of the corresponding elements in L & M. For
instance, if L- [3,1,4] and M=[1,5,9], then N should equal [4,6, 13].

Coding:-

Output:-
Q11: Write a program that rotates the elements of a list so that the element at the first index moves to the
second index, the element in the second index moves to the third index, etc., and the element in the last
index moves to the first index.

Coding:

Output:-
Q12:Write a program that interactively creates a nested tuple to store the marks in three subjects for five
students. Also write a function that computes total marks & average marks obtained by each student.

Coding:-

Output:-
Q13: Write a program using function in Python to count and display the number of lines starting with
alphabet ‘A’ present in a text file “LINES.TXT”. Raise an error if the file is not present.

Coding:-

Output:-
Q14:Write a program to count the number of uppercase and lower case alphabets present in a text file
“Article.txt”.

Coding:-

Output:-
Q15: Write a program to create a CSV file and store empno, name and salary of employees of an
organisation. Run following menu on the file:-

1. Display the data in formatted format

2. Add records

3. Delete data of an employee depending on employee no.

4. Modify name of an employee depending on employee no

5. Search an employee on the basis of name and display the data

6. Count number of records


Output:-
Q16:Write a program to create a binary file “Result.dat” containing rollno, name and percentage of students
of a class. Then append records in the file. Coding:-

Output:-
Q17: Write a program to modify records in the binary file “Result.dat”.

Coding:

Output
:-
Q18: Write a program to display all those records where percentage is greater than 75% from the binary file
“Result.dat”.

Coding:

Output:-
Q19:Write a program to delete the third record from the binary file “Result.dat”.

Output:-
Coding:

I
CREATE TABLE CARHUB(‘VCode’ int primary key,’VehicleName’ varchar(20), ‘Make’
varchar(20) ,’Color’ varchar(20) , ‘Capacity’ int(2), ‘Charges’ int(2) );

CREATE TABLE CUSTOMER(‘CCode’ int primary key, ‘CName’ varchar(20), ‘VCode’ varchar(3));

II
INSERT INTO CARHUB(‘100’,’Innova’,’Toyota’,’WHITE’,’7’,’15’);
INSERT INTO CARHUB(‘102’,’SX4’,’Suzuki’,’BLUE’,’4’,’14’);
INSERT INTO CARHUB(‘104’,’C Class’,’Mercedes’,’RED’,’4’,’35’);
INSERT INTO CARHUB(‘105’,’A-Star’,’Suzuki’,’WHITE’,’3’,’14’);
INSERT INTO CARHUB(‘108’,’Indigo’,’Tata’,’SILVER’,’3’,’12’);

INSERT INTO CUSTOMER(‘1’,’Hemant Sahu’,’101’);


INSERT INTO CUSTOMER(‘2’,’Raj Lal’,’108’);
INSERT INTO CUSTOMER(‘3’,’Feroza Shah’,’105’);
INSERT INTO CUSTOMER(‘4’,’Ketan Dhal’,’104’);

III
SELECT VehicleName FROM CARHUB WHERE Color=’WHITE’;

IV
SELECT VehicleName , Make , Capacity FROM CARHUB ORDER BY ‘Capacity’;
V
SELECT MAX(Charges) FROM CRAHUB;

VI
SELECT CUSTOMER.CName , CARHUB.VehicleName FROM CARHUB , CUSTOMER WHERE
CARHUB.VCode = CUSTTOMER.VCode ;
Coding:-
Coding:-

Output:-
Coding:-

Output:-
Q24:Write a program to delete record of a particular player on the basis of name of the player in the table
“PLAYERS” in the database “SPORTS”. If the player does not exist then display appropriate message.

Coding:-

You might also like