Only the compilation of your submitted code will be tested. No tests have been added yet to check if your code also performs the required tasks. Your final submission before the deadline will be evaluated with automated tests and manually by the instructor for improvement.

Task

In this exercise, we are programming a portfolio that manages financial shares. For this purpose, we define two classes, namely Share (which represents a share) and Wallet (which represents the share portfolio).

Part 1: The Share Class

The Share class represents a single financial share and has the following instance variables:

Constructor of Class Share

The constructor of the Share class initializes a share with a given symbol and quantity:

__init__(symbol, quantity)

Part 2: The Wallet Class

Create a Python class called Wallet. It contains methods to add, remove, and retrieve share, as well as calculating the total value of the portfolio based on specified hare prices.

Instance Variables

An object of the Wallet class contains the following instance variable:

Constructor

The constructor of the Wallet class initializes an empty list of share.

__init__()

Methods to Manipulate Stocks

The Wallet class contains methods to add and remove share:

# Add a new stock to the portfolio
def add_share(self, symbol, quantity)

# Remove a specific quantity of share from the portfolio
def remove_share(self, symbol, quantity)

Methods to Retrieve Stock Information

For retrieving information about share, the following methods are available:

# Get the quantity of share for a given symbol
def get_share_quantity(self, symbol)

Portfolio Evaluation

To calculate the total value of the portfolio based on specified stock prices, the class includes:

# Calculate the total value of the portfolio
def get_portfolio_value(self, prices)

Note: The get_portfolio_value method considers only those share for which prices are specified and calculates the total value by multiplying the quantity of share by their corresponding price. Prices are specified in a list of pairs (also a List) with the stock symbol as the first element and the price as the second element.