Create two classes, Artist and Painting.
Create an artist, with name: str and painting: Painting attributes
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: |
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
Create a class, Shoe
Create a shoe, s, with one attribute, size.
Add 1 to s's size
Create a class, Cup
Create a cup, c, with two attributes, color and volume.
Change c's color
Add 50 to c's volume
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 one class, Animal.
Create an animal, a1, with name: str attribute
Create an animal, a2, with name: str and friend: Animal attributes
Create two classes, School and Student.
Create a school and add some students to its students: list attribute.
Add one more student to school.
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 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.