From bf69f2bdbe301f089f228fba6ad4521a6c58405a Mon Sep 17 00:00:00 2001 From: nj4710 Date: Wed, 25 May 2016 21:23:37 +0530 Subject: [PATCH 1/3] Create Python-Function-Hex.md For issue #819 --- Python-Function-Hex.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 Python-Function-Hex.md diff --git a/Python-Function-Hex.md b/Python-Function-Hex.md new file mode 100644 index 0000000000..45226d7e22 --- /dev/null +++ b/Python-Function-Hex.md @@ -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) From 6b19e0104d769b9d4d3888db7bef96430931e208 Mon Sep 17 00:00:00 2001 From: nj4710 Date: Wed, 25 May 2016 21:58:20 +0530 Subject: [PATCH 2/3] Update Python-Function-Hex.md --- Python-Function-Hex.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Python-Function-Hex.md b/Python-Function-Hex.md index 45226d7e22..1f4c5cf457 100644 --- a/Python-Function-Hex.md +++ b/Python-Function-Hex.md @@ -4,7 +4,7 @@ ## Argument -This function takes one argument `x` that should be of integer type. +This function takes one argument, `x`, that should be of integer type. ## Return From 28ab2c9c8ab29335c62961d2c4bc1b66cc98a9b5 Mon Sep 17 00:00:00 2001 From: nj4710 Date: Thu, 26 May 2016 16:25:42 +0530 Subject: [PATCH 3/3] Update Python-Function-Hex.md --- Python-Function-Hex.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Python-Function-Hex.md b/Python-Function-Hex.md index 1f4c5cf457..56572c05cc 100644 --- a/Python-Function-Hex.md +++ b/Python-Function-Hex.md @@ -13,11 +13,11 @@ 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 +print(hex(16)) # prints 0x10 +print(hex(-298)) # prints -0x12a +print(hex(543)) # prints 0x21f ``` -:rocket: [Run Code](https://repl.it/CVCR) +:rocket: [Run Code](https://repl.it/CV0S) [Official Documentation](https://docs.python.org/3/library/functions.html#hex)