Practical Questions For Record
Practical Questions For Record
Practical Questions For Record
SN PROGRAM
O
1 A Binary file, CINEMA.DAT has the following structure:
{MNO:[MNAME, MTYPE]}
Where
MNO – Movie Number
MNAME – Movie Name
MTYPE is Movie Type
Write a user defined function, findType(mtype), that accepts mtype as parameter
and displays all the records from the binary file CINEMA.DAT, that have the value
of Movie Type as mtype.
SOLUTION:
4 Write a Program in Python that defines and calls the following user defined
functions:
a) ADD() – To accept and add data of an employee to a CSV file ‘record.csv’. Each
record consists of a list with field elements as empid, name and mobile to store
employee id, employee name and
employee salary respectively.
b) COUNTR() – To count the number of records present in the CSV file named
‘record.csv’.
SOLUTION:
5 Write a Program in Python that defines and calls the following user defined
functions:
a) add() – To accept and add data of an employee to a CSV file ‘furdata.csv’. Each
record consists of a list with field elements as fid, fname and fprice to store
furniture id, furniture name and furniture
price respectively.
b) search()- To display the records of the furniture whose price is more than 10000.
SOLUTION:
10 Write a random number generator that generates random numbers between 1 and 6
(simulates a dice).
Solution:
import random
min = 1
max = 6
roll_again = "y"
while roll_again == "y" or roll_again == "Y":
print("Rolling the dice...")
val = random.randint (min, max)
print("You get... :", val)
roll_again = input("Roll the dice again? (y/n)...")