TORONTO KIDS COMPUTER CLUB | Tuesday 17:00 Python Practice – QUIZ03.
20914
post-template-default,single,single-post,postid-20914,single-format-standard,ajax_fade,page_not_loaded,,qode-theme-ver-7.6.2,wpb-js-composer js-comp-ver-6.8.0,vc_responsive

Tuesday 17:00 Python Practice – QUIZ03.

02 Aug Tuesday 17:00 Python Practice – QUIZ03.

1. Which of the following statements is true?
  A. A class is blueprint for the object.
  B. You can only make a single object from the given class.
  C. Both statements are true.
  D. Neither statement is true.

2. What does the __init__() the function do in Python?
  A. Initializes the class for use.
  B. This function is called when a new object is instantiated.
  C. Initializes all the data attributes to zero when called.
  D. None of the above.

3. The correct way to instantiate(create object instance of) the following Dog class is:
   class Dog:
       def __init__(self, name, age):
           self.name = name
           self.age = age

  A. Dog.__init__("Rufus", 3)
  B. Dog("Rufus", 3)
  C. Dog()
  D. Dog.create("Rufus", 3)

4. Which of the following does not correctly create an object instance?
  A. puppy = Dog("Jamie")
  B. dog = Dog("Jamie")
  C. jamie = Dog()
  D. pupper = new Dog("Jamie")

5. In Python, a function within a class definition is called a:
  A. a class function
  B. an operation
  C. a callable
  D. a method
  E. a factory

6. What is the output of the following code? 
   class Foo: 
       def printLine(self, line='Python'): 
           print(line) 
   o1 = Foo() 
   o1.printLine('Java')

  A. Python
  B. Line
  C. Java
  D. Java Python

7. What does the following code output?
   class People():
       def __init__(self, name):
          self.name = name

       def namePrint(self):
           print(self.name)

   person1 = People("Sally")
   person2 = People("Louise")
   person1.namePrint()

  A. Sally
  B. Louise
  C. Sally Louise
  D. person1

8.  In which of the following does the CricketFan class correctly inherit from the PartyAnimal class?
  A. from party import PartyAnimal
  B. class CricketFan(PartyAnimal)
  C. an = PartyAnimal()
  D. CricketFan = PartyAnimal()

9. What’s the output of the following code?
   class Dog:
       def walk(self):
           print("*walking*")

       def speak(self):
           print("Woof!")

   class JackRussellTerrier(Dog):
       def speak(self):
          print("Arff!")

   bobo = JackRussellTerrier()
   bobo.speak()

  A. Woof!
  B. *walking*
  C. AttributeError: 'JackRussellTerrier' object has no attribute 'walk'
  D. Arff!

10. Which pygame function is used to set the size of the window?
  A. pygame.display.set_mode()
  B. pygame.display.set_size()
  C. pygame.display.set_screen()
  D. none

11. Which function in pygame is used to draw rectangle ?
  A. pygame.draw.rect()
  B. pygame.draw.rectangle()
  C. pygame.draw_rect()
  D. none

12. Which tuple of RGB code is representing the color black ?
  A. (0,0,0)
  B. (255,255,255)
  C. (0,255,0)
  D. (0,0,255)

13. Which pygame function is used to quit the python window ?
  A. pygame.quit()
  B. pygame.exit()
  C. pygame.terminate()
  D. none
No Comments

Sorry, the comment form is closed at this time.