Shreyas is a programmer, who has recently been given a task to write a user defined function named write_bin ( ) to create a binary file called Cust_file.dat containing customer information - customer number (c_no), name (c_name), quantity (qty), price (price) and amount (amt) of each customer. The function accepts customer number, name, quantity and price. Thereafter, it displays the message 'Quantity less than 10..... Cannot SAVE', if quantity entered is less than 10. Otherwise the function calculates amount as price * quantity and then writes the record in the form of a list into the binary file.
Write the correct statement to open a file 'Cust_file.dat' for writing the data of the customer.
Fill in the blank:
________ is not a valid built-in function for list manipulations.
Write any two differences between a constructor and a destructor function declared inside a class.
Illustrate with the help of a suitable example.
What will be the output of the following Python code?
V = 25 def Fun(Ch): V=50 print (V, end=Ch) V *= 2 print(V, end=Ch) print(V, end="*") Fun("!") print(V)
Explain the use of a default parameter in a Python function with the help of a suitable example.
Assume that the file STOCK.DAT, is created with the help of objects of class Stock, which is defined below:
class Stock(object): def init(self,N='',P=0): self.SName=N self.Price=P
Write a definition for function Billing() in Python to read each record of a pickled file STOCK.DAT, and display the Total Price of all the records in the file.
Select the correct output of the code:
S= "Amrit Mahotsav @ 75" A=S.partition (" ") print (a)
State True or False.
Comments are not executed by interpreter.
Write functions in Python for InsertQ(Names) and RemoveQ(Names) for performing insertion and removal operations with a queue of list which contains names of students. The function must check for Empty Queue.
What is the output of the following Python code?
def ListChange(): for i in range(len(L)): if L[i] % 2 == 0: L[i] = L[i] * 2 if L[i] % 3 == 0: L[i] = L[i] * 3 else: L[i] = L[i] * 5 L = [2, 6, 9, 10] ListChange() for i in L: print(i, end="#")