Pa - 1 CS (FH)

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

Computer science(083)

Q,No Question Marks


1 Which of the following functions changes the position of file pointer and returns its new position? 1
a.flush() b.tell() c.seek() d.offset()
2 Which of the following mode keeps the file offset position at the end the file 1
a. r+ b. w c. a d.r
3 In a stack all deletions take place at _____ end. 1
a. Front b.Top c. Rear d. End
4 Q17 and 18 are ASSERTION AND REASONING based questions. Mark the correct choice as 1
a. Both A and R are true and R is the correct explanation for A
b. Both A and R are true and R is not the correct explanation for A
c. A is True but R is False
d. A is false but R is True
5 Assertion (A):CSV file stands for Comma Separated Values. 1
Reason(R):CSV files are common file format for transferring and storing data
6 Assertion (A): A stack is a LIFO structure. 1
Reason(R): Any new element pushed into the stack always gets positioned at index after the last
existing in stack.
Section_ B
7 How is metod write() different from writelines()? 2
8 What is the use of pickle module? 2
9 a. What is file mode? 3
b. What is a file pointer?
10 1. A binary file “salary.DAT” has structure [employee id, employee name, salary]. 3
.Write a function countrec() in Python that would read contents of the file “salary.DAT”
and enter the name to update the marks..
11 A binary file “students.dat” has structure (admission_number, Name, Percentage, subject). 3
Write a function countrec() in Python that would read contents of the file and display the
details of those students whose subject is “Biology” and percentage is below 45%. Also display
the number of such students.
12 A list contains following record of customer: 3
[Customer_name, Room Type].
Write the following user defined functions to perform given operations on the stack named
'Hotel' :
(i) To Push customers' names of those customers who are staying in 'Delux' Room Type.
(ii) To Pop the names of customers from the stack and display them.
Also, display "Underflow" when there are no customers in the stack.

For example :
If the lists with customer details are as follows :
["Siddarth", "Delux"]["Rahul", "Standard"]["Jerry", "Delux"]
The stack should contain
Jerry
Siddharth
The output should be:
Jerry
Siddharth
Underflow
13 Write a function in Python, Push (Vehicle) where, Vehicle is a dictionary containing 3
details of vehicles – {Car_Name: Maker}.
The function should push the name of car manufactured by 'TATA' (including all the
possible cases like Tata, TaTa, etc.) to the stack.
For example:
If the dictionary contains the following data:
Vehicle={ "Santro": "Hyundai", "Nexon": "TATA", "Safari": "Tata" }.
The stack should contain
Safari
Nexon

14 Define binary file. 5


Write a python program to create a binary file player.dat and write 10 records in it, player id,
name,sports Display those player details whose sports is athletic.
15 Why it is important to close a file before exiting? 5
Write a program in Python that defines and calls the following user defined functions:
i) Add_Book: Takes the details of the books and adds them to a csv file 'Book.csv'. Each record
consists of a list with field elements as book_ID, B_ name and pub to store book ID, book name
and publisher respectively.
(ii) Search_Book: Takes publisher name as input and counts and displays number of books
published by them.

You might also like