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
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 a class, any instance of it, save them to variables, and assign any attribute to this instance.
Create two classes, Recipe and Ingredient.
Create some ingredients with one attribute, name.
Create a recipe and add created ingredients to its ingredients: tuple attribute.
Print the name of the first ingredient of the created recipe.
Create two classes, Company and Employee.
Create some employees and assign their names.
Create two companies, add an employees: set attribute and add some employees to each of the companies.
Check if there's any employee working in both companies and print them.
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 Company:
"""Represents a company."""
What is the name of the defined class in the script above?
class Bakery:
pass
class Cake:
pass
c1, c2 = Cake(), Cake()
c1.name, c2.name = "Chocolate", "Vanilla"
b = Bakery()
b.cakes = [c1, c2]
c = b.cakes.pop(-1)
print(c.name)
What is printed when we execute the above script
Create a class named Book
Create an instance of Book and assign it to book
Assign two attributes to book, title and pages, with values "Of Mice And Men" and 120 respectively.
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: |