\documentclass[10pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage[a4paper,margin=1.5cm,includefoot]{geometry}
\usepackage{amssymb}
\usepackage[frenchb]{babel}
\usepackage{colortbl}
\usepackage{listingsutf8}
\usepackage{tikz}
\newlength\largeurboxlisting
\newsavebox{\pythonbox}%
\lstnewenvironment{python}[1][5]{%
\begingroup\lrbox{\pythonbox}%
\lstset{%
language = python,
inputencoding=utf8,
basicstyle = \ttfamily,
numbers = left,
numberstyle = \color{gray}\tiny,
tabsize = 2,
showstringspaces = false,
keywordstyle = \color{orange}\bfseries,
commentstyle = \color{green!50!black}\itshape,
stringstyle=\color{yellow!50!black},
emph = {somme},
emphstyle = \color{red!50!black},
literate=
{á}{{\'a}}1 {é}{{\'e}}1 {í}{{\'i}}1 {ó}{{\'o}}1 {ú}{{\'u}}1
{Á}{{\'A}}1 {É}{{\'E}}1 {Í}{{\'I}}1 {Ó}{{\'O}}1 {Ú}{{\'U}}1
{à}{{\a}}1 {è}{{\e}}1 {ì}{{\i}}1 {ò}{{\o}}1 {ù}{{\u}}1
{À}{{\A}}1 {È}{{\'E}}1 {Ì}{{\I}}1 {Ò}{{\O}}1 {Ù}{{\`U}}1
{ä}{{\"a}}1 {ë}{{\"e}}1 {ï}{{\"i}}1 {ö}{{\"o}}1 {ü}{{\"u}}1
{Ä}{{\"A}}1 {Ë}{{\"E}}1 {Ï}{{\"I}}1 {Ö}{{\"O}}1 {Ü}{{\"U}}1
{â}{{\^a}}1 {ê}{{\^e}}1 {î}{{\^i}}1 {ô}{{\^o}}1 {û}{{\^u}}1
{Â}{{\^A}}1 {Ê}{{\^E}}1 {Î}{{\^I}}1 {Ô}{{\^O}}1 {Û}{{\^U}}1
{Ã}{{\~A}}1 {ã}{{\~a}}1 {Õ}{{\~O}}1 {õ}{{\~o}}1
{œ}{{\oe}}1 {Œ}{{\OE}}1 {æ}{{\ae}}1 {Æ}{{\AE}}1
}%
}{%
\endlrbox\endgroup
\settowidth{\largeurboxlisting}{\usebox\pythonbox}%
\ifnum\theenumi>0
\noindent
\fi%
\tikz\node[%
rounded corners = 3pt,
line width = 1pt ,
draw = blue!50!black ,
fill = blue!10 ,
inner sep = 3mm] {
\begin{minipage}{\dimexpr\largeurboxlisting+#1mm}
\ifnum\theenumi>0
\hspace{-\leftmargini}%
\ifnum\value{enumii}>0
\hspace{-\leftmarginii}%
\fi%
\fi%
\hspace*{#1mm}\usebox\pythonbox
\end{minipage}
};
}
\begin{document}
\textbf{Exercice 1 : Arbres binaires de recherche, POO et récursivité - 10 points}
\begin{python}
class Noeud:
def __init__(self, g, v, d):
"""crée un noeud d'un arbre binaire"""
self.gauche = g
self.valeur = v
self.droit = d
\end{python}
\begin{enumerate}
\item et là, ça ne va plus :
\begin{python}
class Noeud:
def __init__(self, g, v, d):
"""crée un noeud d'un arbre binaire"""
self.gauche = g
self.valeur = v
self.droit = d
\end{python}
\begin{enumerate}
\item et là, ça ne va plus :
\begin{python}
class Noeud:
def __init__(self, g, v, d):
"""crée un noeud d'un arbre binaire"""
self.gauche = g
self.valeur = v
self.droit = d
\end{python}
\end{enumerate}
\end{enumerate}
\end{document}
\end{document}
![alt text][1]
[1]: https://texnique.fr/osqa/upfiles/Screenshot_2023-12-19_at_14.14.46.png