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 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
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, 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.
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 named Computer
Create an instance of Computer and assign it to pc
Assign two attributes to pc, brand and ram, with values "Lenovo" and 16 respectively.
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.
Create two classes, Market and Product.
Create four products and assign a name and a price to each.
Create two markets and add some products to their products: list attribute.
Print number of products of the first market.
Print total product value of the second market.
Create one class, Dog.
Create a dog, dad, with name: str attribute
Create a dog, puppy, with name: str and parent: Dog attributes
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.