class House:
"""Represents a house.
attributes: owner, address
"""
class Owner:
"""Represents a house owner.
attributes: name
"""
class Address:
"""Represents an address.
attributes: street
"""
person = Owner()
person.name = "Blerina"
addr = Address()
addr.street = "Rr. Iliria"
h = House()
h.owner, h.address = person, addr
Given the above script:
| What is type of h.owner: | ||
| What is value of h.owner.name: |
Create two classes, Book and Author.
Create an author, writer, with name and age attributes
Create a book, novel, with title: str, pages: int and author: Author attributes.
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 a class, Building
Create a building, b, with attribute floors, name, and elevators.
Add one more elevator to b.
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: |
Create two classes, Zoo and Animal.
Create some animals with one attribute, name.
Create a zoo and add created animals to its animals: set attribute.
Add one more animal to the zoo.
Create a class named Car
Create an instance of Car and assign it to car1
Assign two attributes to car1, brand and year, with values "BMW" and 2020 respectively.
Create classes Movie, Director, and Actor.
Create a director, d with name attribute.
Create an actor, a, with name attribute.
Create a movie, m, with title: str, director: Director and main_actor: Actor attributes
Create one class, Animal.
Create an animal, a1, with name: str attribute
Create an animal, a2, with name: str and friend: Animal attributes
Create a class, Shoe
Create a shoe, s, with one attribute, size.
Add 1 to s's size