Practice Questions Class12 Cs
Practice Questions Class12 Cs
Write a user
defined function insertRec() to input data for a student and add to student.dat. ii.
Write a function searchRollNo( r ) in Python which accepts the student’s rollno as
parameter and searches the record in the file “student.dat” and shows the
details of student i.e. rollno, name and marks (if found) otherwise shows the
message as ‘No record found’.
2. A binary file “emp.dat” has structure [EID, Ename, designation, salary]. i. Write
a user defined function CreateEmp() to input data for a record and create a file
emp.dat. ii. Write a function display() in Python to display the detail of all
employees whose salary is more than 50000.
3. A binary file named “EMP.dat” has some records of the structure [EmpNo,
EName, Post, Salary] (a) Create a binary file “EMP.dat” that stores the records of
employees and display them one by one. (b) Display the records of all those
employees who are getting salaries between 25000 to 30000
4. (i) A binary file “book.dat” has structure[BookNo,
Book_name,Author ,Price].
(a) Write a user defined function CreateFile() to input data for record and
add to Book.dat.
(b) Write a function countRec(Author) in python which accepts the Author
name as parameter and count and return number of books by the given Author
are stored in binary file
“Book.dat”
Write a function in python to count the number lines in a text file ‘Country.txt’
which is starting with an alphabet ‘W’ or ‘H’.