from typing import Dict


def get_opt_value(result_data: Dict, param_name: str) -> float:
    """A helper function to get parameter value from a result dictionary.

    Args:
        result_data: Result data.
        param_name: Name of parameter to extract.

    Returns:
        Parameter value.

    Raises:
        KeyError:
            - When the result does not contain parameter information.
        ValueError:
            - When specified parameter is not defined.
    """
    try:
        index = result_data["popt_keys"].index(param_name)
        return result_data["popt"][index]
    except KeyError as ex:
        raise KeyError(
            "Input result has not fit parameter information. "
            "Please confirm if the fit is successfully completed."
        ) from ex
    except ValueError as ex:
        raise ValueError(f"Parameter {param_name} is not defined.") from ex