Pructor Quiz 7 by anupmaurya June 12, 2021 written by anupmaurya 0 comment Welcome to your Prutor Python Quiz 8 In python, a class is created by keyword, and to create of the class, we will have to use constructor of class. a) def, file b) class, object c) self, .py file d) None of these What will be the output of the following python code? class Roll: def init(self, id): self.id = id id = 231 return idval = Roll(321)print (val.id) a) TypeError b) 231 c) 321 d) None of these What will be the output of following python code? class X: def init(self): self.a = 10 self._b = 20 self.b = 20 def getB(self): return self.bx = X()x._b = 60print(x.getB()) a) 20 b) 60 c) Error d) Program runs but does not print anything Private method in python starts with _____ while protected methods starts with _________. a) #, @ b) double underscore, single underscore c) single underscore,double underscore d) None of these What will be the output of the following code. Code is saved in a file named 'code.py' : f = open('file.txt') f.readlines() print(f.name) print ( f.closed ) f.close() print ( f.closed ) a) Error b) code.py False True c) code.py True False d) file.txt False True Time's up Share 0 FacebookTwitterLinkedinRedditWhatsappTelegramEmail anupmaurya Hey there, My name is Anup Maurya. I was born with love with programming and works at TCS. One of best global (IT) services and consulting company as System Administrator . I also love graphics designing. It's my pleasure to have you here. previous post Python Quiz next post Pructor Python Quiz 6 Leave a Comment Cancel Reply Save my name, email, and website in this browser for the next time I comment. * By using this form you agree with the storage and handling of your data by this website.