class Owl: """Represents an owl.""" huti = Owl() bufi = Owl()
Given the above script
How many classes are defined: | ||
How many objects are created: | ||
What class does the object huti belong to: | ||
What class does the object bufi belong to: |
Create a class, Car
Create a dog, my_car, with two attributes, brand and year.
Change my_car's brand
Add one year to my_car
Create two classes, Bird and Nest.
Create a bird, with species: str and nest: Nest attributes.
Create a class named Dog
Create a dog, dog, with two attributes, name and age.
Change dog's name
Add one year to dog
class Room: pass r = Room() r.name = "Living Room" r.lights_on = False r.lights_on = True
What is the value of the following expressions at the end of execution of the above script?
r.name: | ||
r.lights_on: |
class Horse: pass h = Horse() h.name = "Storm" h.age = 5 h.color = "Brown" h.color = "Black" h.age += 2
What is the value of the following expressions at the end of execution of the above script?
h.color: | ||
h.age: |
class Hospital: pass class Doctor: pass d1, d2 = Doctor(), Doctor() d1.name, d2.name = "Dr. Liri", "Dr. Mirlinda" h = Hospital() h.staff = {"cardiology": d1, "urologji": d2} print(h.staff["urologji"].name)
What is printed when we execute the above script
class Person: """Represents a person. attributes: name, best_friend """ p1 = Person() p1.name = "Arta" p2 = Person() p2.name = "Zana" p2.best_friend = p1
Given the above script:
What is type of p2.best_friend: | ||
What is value of p2.best_friend.name: |
Create two classes, Backpack and Student.
Create a backpack, bp, with color attribute
Create a student, st, with name: str, grade: int and bag: Backpack attributes.
Create one class, Dog.
Create a dog, dad, with name: str attribute
Create a dog, puppy, with name: str and parent: Dog attributes