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 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 a class named Dog
Create a dog, dog, with two attributes, name and age.
Change dog's name
Add one year to dog
Create a class, Cup
Create a cup, c, with two attributes, color and volume.
Change c's color
Add 50 to c's volume
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 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 that represents phone
Create an instance of it and assign it to ph
Assign three attributes to it, model, price and year, with values a string, a float and an integer respectively.
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 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, Building
Create a building, b, with attribute floors, name, and elevators.
Add one more elevator to b.