parskip - customized spacing for code listing and equations

I'm writing a book in which I'm going to insert a lot of code listings (using minted). Usually, a code listing is followed by the output of the execution (either an equation, or plain text formatted with \texttt{}). In some cases, it could be followed by another text paragraph explaining what the code does.

I'm also using the package parskip: I like having spaces between text paragraphs, as well as no indentation. However, weird spacing is troubling me with code listings and equations, as we can see in the following example:

\documentclass[a4paper,12pt]{book}
\usepackage[top=1in, bottom=1in, left=1.1in, right=1in]{geometry}

\usepackage{parskip}

\usepackage{bm} % math bold italic font
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

\usepackage{amsmath}
\usepackage{amsfonts} % display R, C, Z, ...
\usepackage{amssymb} % \veebar

\usepackage{caption}
\DeclareMathOperator\erf{erf} % error function
\DeclareMathOperator\modf{frac} % fractionalpart
\usepackage[multiple]{footmisc} % multiple footnotes at one point

\usepackage{hyperref}
\usepackage{xurl} % autowrap long urls in footnotes
\urldef{\texurl}\url{tex.stackexchange.com/}

\usepackage{enumitem} % characters instead of numbers in enumerate lists
\usepackage{tabularx}
\usepackage{makecell}

\usepackage{minted}
\usepackage[dvipsnames, table]{xcolor}
\definecolor{lightgray}{rgb}{0.9, 0.9, 0.9}
\setminted[python]{bgcolor=lightgray, breaklines}
%\BeforeBeginEnvironment{minted}{\vspace{-5pt}}
%\AtBeginEnvironment{minted}{\setlength{\parskip}{-4pt}} % reduce empty vertical space after minted paragraph

\usepackage{tikz}
\usetikzlibrary{arrows.meta,angles,shapes.arrows,calc}
\usetikzlibrary{decorations.pathmorphing,patterns}
\usetikzlibrary{decorations.pathmorphing,decorations.markings}

\usepackage{lipsum}

\begin{document}

\lipsum[1][1-3]\footnote{\texurl}

\begin{minted}[baselinestretch=0.8]{python}
a = cos(x)**x / (2 + exp(x))
a
\end{minted}
$$\frac{\cos^{x}{\left(x \right)}}{e^{x} + 2}$$

\lipsum[1][1-3]

\lipsum[1][1-3]

\begin{minted}{python}
print(isinstance(a, int))
\end{minted}
{\centering\texttt{False}\par}

\lipsum[1][1-3]
$$\begin{gathered} y = m x + q \\ y = m x + q \end{gathered}$$

\lipsum[1][1-3]

\lipsum[1][1-3]

\begin{minted}{python}
# line of code
\end{minted}

\lipsum[1][1-3]

\lipsum[1][1-3]

\end{document}


The picture shows the current situation: in general, I would love to reduce the white space around the equation below the code listings. In the second code listing, the "output" text is placed very far away: I would love to reduce that spacing. In the last code listing, there is just too much white space after it. Ideally, I would love for each code listing and the next paragraph to be treated as one paragraph, thus not having spacing between them...

I've played with \BeforeBeginEnvironment{minted} and \AtBeginEnvironment{minted}, unfortunately I'm unable to achieve what I desire.

Which brings me to this post: what can I change? Are there alternatives to parskip?