<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_named_arg(name, default_val=None, reqd=False):
 """ Extract the value after a command-line flag such as '-f' and return it. If the command-line flag is missing, return default_val. If reqd == True and the command-line flag is missing, throw an error. Parameters name : str command line flag, e.g. "-f" default_val value to use if command line flag is missing, e.g. "measurements.txt" default is None reqd : bool throw error if reqd==True and command line flag is missing. if reqd == True, default_val will be ignored. default is False. Returns --------- Desired value from sys.argv if available, otherwise default_val. """

    if name in sys.argv:  # if the command line flag is found in sys.argv
        ind = sys.argv.index(name)
        return sys.argv[ind + 1]
    if reqd:  # if arg is required but not present
        raise MissingCommandLineArgException(name)
    return default_val