\documentclass[a4paper, 12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[brazil]{babel}
\usepackage{listings}
\usepackage{color}
 
\definecolor{dkgreen}{rgb}{0,0.6,0}
\definecolor{gray}{rgb}{0.5,0.5,0.5}
\definecolor{mauve}{rgb}{0.58,0,0.82}
 
\lstset{
  language=Python,                
  basicstyle=\footnotesize,           
  numbers=left,                   
  numberstyle=\tiny\color{gray},  
  stepnumber=2,                             
  numbersep=5pt,                  
  backgroundcolor=\color{white},    
  showspaces=false,               
  showstringspaces=false,         
  showtabs=false,                 
  frame=single,                   
  rulecolor=\color{black},        
  tabsize=2,                      
  captionpos=b,                   
  breaklines=true,                
  breakatwhitespace=false,        
  title=\lstname,                               
  keywordstyle=\color{blue},          
  commentstyle=\color{dkgreen},       
  stringstyle=\color{mauve},     
}

\title{Coding Python}
\author{Leonardo}
\date{}

\begin{document}

\subsection*{Código em Python}

\begin{lstlisting}
    print 'Hello world!'
    for i in range(0,10):
        print i # print numbers from 0 to 9
\end{lstlisting}

\subsection*{Código em C}

\lstset{language=C}
\begin{lstlisting}
    int i;
    puts("Hello world!")
    for (i=0; i<10; i++):
        printfl("%d", i) /* print numbers from 0 to 9 */
\end{lstlisting}

\subsection*{Código em Java}

\lstset{language=Java}
\begin{lstlisting}
    System.out.println("Hello world!")
    for (int i=0; i<10; i++):
        System.out.println(i) // print numbers from 0 to 9 
\end{lstlisting}

\end{document}
