forked from freeCodeCamp/wiki
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
For issue freeCodeCamp#819
- Loading branch information
Showing
1 changed file
with
23 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Python hex(x) | ||
|
||
`hex(x)` is a built-in function in Python 3 to convert an integer number to a lowercase [hexadecimal](https://www.mathsisfun.com/hexadecimals.html) 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 | ||
|
||
```python | ||
print hex(16) # prints 0x10 | ||
print hex(-298) # prints -0x12a | ||
print hex(543) # prints 0x21f | ||
``` | ||
|
||
:rocket: [Run Code](https://repl.it/CVCR) | ||
|
||
[Official Documentation](https://docs.python.org/3/library/functions.html#hex) |