0% found this document useful (0 votes)
3 views3 pages

Practical Practice

The document contains a series of programming tasks in Python, including functions for counting character occurrences, managing hotel records, querying a product database, handling student records in CSV format, and processing loan data. It also includes operations for binary file management and sports data analysis. Each task requires specific data manipulations and outputs based on given conditions.

Uploaded by

bgmi90800
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)
3 views3 pages

Practical Practice

The document contains a series of programming tasks in Python, including functions for counting character occurrences, managing hotel records, querying a product database, handling student records in CSV format, and processing loan data. It also includes operations for binary file management and sports data analysis. Each task requires specific data manipulations and outputs based on given conditions.

Uploaded by

bgmi90800
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

Q.

1-Write a function called AMCount() in python which should read each character of a text
file ‘[Link]’ and display the total no of occurrences of letters A and M including lowercase
a and m.
4
Q.2-Write A menu based program to add, delete, and display the record of hotel using list as
4 stack data structure in [Link] record of hotel contains fields Hotel no, total_customer
and Total_rooms.
Q.3-Consider a database PRODUCTS with the following table:
4
PRODUCTS

PCODE PNAME COMPANY PRICE STOCK MANUFACTURE WARRANTY


P001 TV BPL 10000 200 2018-01-12 3
P002 TV SONY 12000 150 2017-03-23 4
P003 PC LENOVO 39000 100 2018-04-09 2
P004 PC COMPAQ 38000 120 2019-6-20 2
P005 HANDYCAM SONY 18000 250 2017-03-23 3
Answer the following questions:
a) Display the details of all PC with stock more than 110.
b) Display the list of COMPANY which gives warranty of more than 2 years.
c) Display the maximum value of Price.
d) Add a new column profit.

Q.1-Write a python program that defines and calls the following user defined functions
a) add() to accept and add data to csv file [Link]. each record consists of a list with field
elements as admno, sname and percentage of marks.
4
b)search() to display the records of the students whose percentage is more than 75.
4
Q.2-Consider a database ORDERS with the following table:
4
ORDERS

ORDERID PNAME QUANTITY RATE SALE_DATE DISCOUNT


1001 PEN 10 20 2019-10-05 NULL
1002 PENCIL 20 10 2019-10-21 NULL
1003 BOOK 10 100 2019-11-02 50
1004 ERASER 100 5 2019-12-05 25
1005 NOTEBOOK 50 20 2019-12-10 NULL
Answer the following questions:
a) Display PNAME,QUANTITY AND RATE for all the orders that are either PENCIL
or PEN.
b) Display the orders which are not getting any of discount.
c) Display PNAME,QUANTITY,and SALE_DATE for all the orders whose
totalcost(QUANTITY*RATE) is greater than 500.
d) Display orders whose RATE is in the range of 20 to 100.

Q.1-Write a function in python countNow(PLACES) that takes the dictionary PLACES as an


argument and displays the name in (uppercase) of the places whose names are longer than
5 characters.
4
Eg-PLACES={1:london,2:delhi} answer should be:LONDON
Q.2- Write a python program to display all the records in a file along with record number.
4
Q.3-Consider a database LOANS with the following table:
4
LOANS

AccNo Cust_Name Loan_Amount Installments Rate St_date Interest


1 [Link] 300000 36 12.00 2009-07-19 1200
2 [Link] 500000 48 10.00 2008-03-22 1800
3 [Link] 300000 36 NULL 2007-03-08 1600
4 [Link] 800000 60 10.00 2008-12-06 2250
5 [Link] 200000 36 12.50 2010-01-03 4500
6 [Link] 700000 60 12.50 2008-06-05 3500
7 [Link] 500000 48 NULL 2008-03-05 3800
Answer the following questions:
a) Display the sum of all loan amounts whose Interest rate is greater than 10.
b) Display the maximum Interest from LOANS.
c) Display the count of all loan holders whose name ends with ‘Sharma’.
d) Display the count of all loan holders whose Rate is NULL.
e) Display the Interest-wise details of loan account holders.(Cust Name)
f) Display the Interest-wise details of loan account holders with atleast 10 installments
remaining.

Q.1-A binary file ‘[Link]’ has structure [BookNo, BookName, Author, Price]
Write a user defined function CreateFile(), to input data for a record and add to ‘[Link]’.
4
Write a function CountRec(Author)in python which accepts Author as a parameter and
counts and returns the no. of books by the given Author that are stored in ‘[Link]’.
4
Q.2-Consider a database SPORTS with the following table:
4
SPORTS

StudentNo Class Name Game1 Grade1 Game2 Grade2


10 7 Sameer Cricket B Swimming A
11 8 Sujit Tennis A Skating C
12 7 Kamal Swimming B Football B
13 7 Veena Tennis C Tennis A
14 9 Archana Basketball A Cricket A
15 10 Arpit Cricket A Athletics C
Answer the following questions:
a) Display the Name of Student who have grade C either in Game 1 or Game2.
b) Display the number of Students getting Grade A in Cricket.
c) Display the Name of Students who have the same Game for both Game1 and Game2.
d) Display the Game taken up by the Students, whose Name starts with ‘A’.
e) Add a new column Marks.
f) Assign a value 200 for Marks for all those who are getting Grade B or Grade A in
both Game1 and Game2.

You might also like