24 lines
		
	
	
		
			783 B
		
	
	
	
		
			Markdown
		
	
	
	
	
	
			
		
		
	
	
			24 lines
		
	
	
		
			783 B
		
	
	
	
		
			Markdown
		
	
	
	
	
	
| ---
 | |
| title: Python Hex Function
 | |
| localeTitle: Função hexadecimal em Python
 | |
| ---
 | |
| `hex(x)` é uma função embutida no Python 3 para converter um número inteiro em uma string [hexadecimal](https://www.mathsisfun.com/hexadecimals.html) minúscula prefixada com “0x”.
 | |
| 
 | |
| ## Argumento
 | |
| 
 | |
| Essa função recebe um argumento, `x` , que deve ser do tipo inteiro.
 | |
| 
 | |
| ## Retorna
 | |
| 
 | |
| Essa função retorna uma seqüência hexadecimal minúscula prefixada com "0x".
 | |
| 
 | |
| ## Exemplo
 | |
| ```
 | |
| print(hex(16))    # prints  0x10 
 | |
|  print(hex(-298))  # prints -0x12a 
 | |
|  print(hex(543))   # prints  0x21f 
 | |
| ```
 | |
| 
 | |
|  [Executar código](https://repl.it/CV0S)
 | |
| 
 | |
| [Documentação Oficial](https://docs.python.org/3/library/functions.html#hex) |