22 lines
		
	
	
		
			836 B
		
	
	
	
		
			Markdown
		
	
	
	
	
	
		
		
			
		
	
	
			22 lines
		
	
	
		
			836 B
		
	
	
	
		
			Markdown
		
	
	
	
	
	
|   | --- | ||
|  | title: Python Hex Function | ||
|  | --- | ||
|  | `hex(x)` is a built-in function in Python 3 to convert an integer number to a lowercase <a href='https://www.mathsisfun.com/hexadecimals.html' target='_blank' rel='nofollow'>hexadecimal</a> string prefixed with “0x”. | ||
|  | 
 | ||
|  | ## Argument
 | ||
|  | 
 | ||
|  | This function takes one argument, `x`, that should be of integer type. | ||
|  | 
 | ||
|  | ## Return
 | ||
|  | 
 | ||
|  | This function returns a lowercase hexadecimal string prefixed with "0x". | ||
|  | 
 | ||
|  | ## Example
 | ||
|  | 
 | ||
|  |     print(hex(16))    # prints  0x10 | ||
|  |     print(hex(-298))  # prints -0x12a | ||
|  |     print(hex(543))   # prints  0x21f | ||
|  | 
 | ||
|  |  <a href='https://repl.it/CV0S' target='_blank' rel='nofollow'>Run Code</a> | ||
|  | 
 | ||
|  | <a href='https://docs.python.org/3/library/functions.html#hex' target='_blank' rel='nofollow'>Official Documentation</a> |