import ast


def count_func_defs(notebook):
    """
       Extracts the number of function definitions from a notebook

       Args:
           notebook(Notebook): python object representing the notebook
       Returns:
           f_num: integer representing the number of function definitions in the code

       A way you might use me is

       function_defs_count = count_func_defs(nb)
    """
    code = notebook.script
    tree = ast.parse(code)
    f_num = sum(isinstance(exp, ast.FunctionDef) for exp in tree.body)
    return f_num