1) Object-oriented programming (OOP) describes... a) the properties of different objects b) different classes and objects in a single unit c) a style or model of programming that uses objects. d) a function that uses objects and classes 2) What is the meaning of object in programming ? a) collection of data and methods as two different units. b) collection of data and methods as a single unit. c) classification of data and methods as a single unit. d) classification of data and methods as two different units 3) Choose the wrong description about class. a) a template or “blueprint” for creating an object. b) one class has only one object c) involves in the making of mini battle game d) if class = vegetables, then objects = carrot, brinjal, tomato 4) Syntax for creating a class is... a) Class num = b) class "fruit" : c) class time ; d) class Teacher : 5) If def __init__ (self, name): , the object could be... a) Ali b) Ali, 8 years old c) Kelvin, 23 August 2009 d) Syazwan, Year 8 6) What is a "method" ? a) An array of elements in a same class b) All the objects in a same class c) A variable used to represent an object d) A function that belongs to a class / object 7) When p.walk(0, 7) is executed, the player... a) walk 7 units right b) walk 7 units down c) walk 7 units up d) walk 7 units left 8) Choose the correct statement. a) self can access variables from other class b) self represents the other object in the same class c) self parameter has no argument d) self is passed as a shown parameter 9) enemy.takeDamage(10) means that... a) enemy will absorb 10 HP from the player b) enemy will lose HP by 10 after each damage c) enemy will die when received damage of 10 d) enemy has only 10 HP left for now 10) When enemy is defeated, which code is not written ? a) print("Enemy defeated!") b) if (self.hp <= 0): c) else d) self.hp = 0 11) Choose the correct explanation about "attribute". a) Attribute is actually a variable belongs to a class b) We can only have one attribute in each class c) No value is needed for attribute d) attribute is named before "self" 12) def __init__ (self, name, age): . Which of the following cannot be its value? a) 23 years 6 months and 26 days  b) 23 years old c) Jonathan d) 3 November 2017

Coding Quiz (12) : Python OOP

Bestenliste

Visueller Stil

Einstellungen

Vorlage ändern

Soll die automatisch gespeicherte Aktivität wiederhergestellt werden?