Pructor Quiz 7 by anupmaurya June 12, 2021 written by anupmaurya June 12, 2021 316 Welcome to your Prutor Python Quiz 8 1. 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 1 out of 5 2. 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 2 out of 5 3. 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 3 out of 5 4. 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 4 out of 5 5. 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 5 out of 5 Time's upTime is Up! 0 comment 0 FacebookTwitterPinterestEmail anupmaurya "Hi there, My name is Anup Maurya. I have a passion for programming and previously worked at TCS, one of the best global IT services and consulting companies, as a System Administrator. I also enjoy graphic design. It's a 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.