When using sagetex the background of sagecommandline environments can be easily changed via lstlistings setup.
How can the background of a sageblock environment be changed?
MWE:
\documentclass[]{article}
\usepackage{sagetex}
\usepackage{xcolor}
\lstset{language=Sage,
commentstyle={\ttfamily\color{green}},
keywordstyle={\ttfamily\color{blue}\bfseries},
stringstyle ={\ttfamily\color{dgraycolor}\bfseries},
tabsize = 4,
basicstyle={\small \ttfamily},
backgroundcolor= \color{orange!20},
}
\begin{document}
The following function computes the square of a number:
\begin{sageblock}
def f(x):
return x**2
\end{sageblock}
Testing in the code gives for $x=2$ the value \sage{f(2)}.
Commandline Version:
\begin{sagecommandline}
sage: x = 2
sage: f(2)
\end{sagecommandline}
\end{document}

