B04C-2015 – Computer Sir Ki Class

Login


Lost your password?

Don't have an account ?
Register (It's FREE) ×
  

Login
[lwa]



Exam Questions-CBSE12A-2015-B04C #PYTHON#6382    siteicon   siteicon  

Problem Statement - B04C-2015

Consider the following definition of class Student. Write a method in python to write the content in a pickled file student.dat

class Student:
    def_init_(self,A,N} :
        self.Admno=A
        self.Name=N
    def Show(self}:
        print (self.Admno, "#" , self.Name}

Solution

TC++ #6382

import pickle 
class Student:
    def __init__(self, A, N):
        self.Admno = A
        self.Name = N
    def show(self):
        print(self.Admno,"#",self.Name)
    def store_data(self):
        piFile = open('student.dat','wb')
        pickle.dump(self, piFile)
        piFile.close()


Share

CSKC| Created: 11-Jan-2019 | Updated: 11-Jan-2019|CBSE12A-2015









Back