From 406f5024a080f0f8d73378598fd8ab625b773e2b Mon Sep 17 00:00:00 2001 From: Arijit Layek Date: Sat, 30 Apr 2016 12:47:19 +0000 Subject: [PATCH 1/4] Add python-abs.md --- python-abs.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 python-abs.md diff --git a/python-abs.md b/python-abs.md new file mode 100644 index 0000000000..7f86b102a8 --- /dev/null +++ b/python-abs.md @@ -0,0 +1,20 @@ +# Python abs(x) + +`abs()` is a built in function in Python 3, to compute the absolute value of any number. It takes one argument `x`. The argument can even be a [complex number](https://docs.python.org/3.0/library/cmath.html), and in that case its [modulus](http://www.mathcentre.ac.uk/resources/sigma%20complex%20number%20leaflets/sigma-complex9-2009-1.pdf) is returned. + +## Argument +It takes one argument `x` - an integer, or decimal, or a complex number. + +## Return Value +The return value would be a positive number. Even if complex number is passed, it would return its magnitude, computed as per complex number algebra. + +## Code Sample + +```python +print(abs(3.4)) # prints 3.4 +print(abs(-6)) # prints 6 +print(abs(3 + 4j)) # prints 5, because |3 + 4j| = 5 +``` +:rocket: [REPL It!](https://repl.it/CL8k/0) + +[Documentation](https://docs.python.org/3/library/functions.html#abs) From a3fe22be008f2dc1c8beac0f039dcbab0d5c077e Mon Sep 17 00:00:00 2001 From: Arijit Layek Date: Sat, 30 Apr 2016 14:04:11 +0000 Subject: [PATCH 2/4] Fix built-in --- python-abs.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python-abs.md b/python-abs.md index 7f86b102a8..35241a3aee 100644 --- a/python-abs.md +++ b/python-abs.md @@ -1,6 +1,6 @@ # Python abs(x) -`abs()` is a built in function in Python 3, to compute the absolute value of any number. It takes one argument `x`. The argument can even be a [complex number](https://docs.python.org/3.0/library/cmath.html), and in that case its [modulus](http://www.mathcentre.ac.uk/resources/sigma%20complex%20number%20leaflets/sigma-complex9-2009-1.pdf) is returned. +`abs()` is a built-in function in Python 3, to compute the absolute value of any number. It takes one argument `x`. The argument can even be a [complex number](https://docs.python.org/3.0/library/cmath.html), and in that case its [modulus](http://www.mathcentre.ac.uk/resources/sigma%20complex%20number%20leaflets/sigma-complex9-2009-1.pdf) is returned. ## Argument It takes one argument `x` - an integer, or decimal, or a complex number. From 34e22eb342d058d0c51fc0449f77cb6a61636306 Mon Sep 17 00:00:00 2001 From: Arijit Layek Date: Sat, 30 Apr 2016 14:54:41 +0000 Subject: [PATCH 3/4] Add some fixes --- python-abs.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/python-abs.md b/python-abs.md index 35241a3aee..ad9648d3b2 100644 --- a/python-abs.md +++ b/python-abs.md @@ -1,4 +1,4 @@ -# Python abs(x) +# Python `abs(x)` `abs()` is a built-in function in Python 3, to compute the absolute value of any number. It takes one argument `x`. The argument can even be a [complex number](https://docs.python.org/3.0/library/cmath.html), and in that case its [modulus](http://www.mathcentre.ac.uk/resources/sigma%20complex%20number%20leaflets/sigma-complex9-2009-1.pdf) is returned. @@ -17,4 +17,4 @@ print(abs(3 + 4j)) # prints 5, because |3 + 4j| = 5 ``` :rocket: [REPL It!](https://repl.it/CL8k/0) -[Documentation](https://docs.python.org/3/library/functions.html#abs) +[Official Docs](https://docs.python.org/3/library/functions.html#abs) From 10437c1bb77e20c7cda529529d5a46556ba8cf32 Mon Sep 17 00:00:00 2001 From: Arijit Layek Date: Sat, 30 Apr 2016 21:20:16 +0000 Subject: [PATCH 4/4] Rename python abs --- python-abs.md => Python-Function-ABS.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename python-abs.md => Python-Function-ABS.md (100%) diff --git a/python-abs.md b/Python-Function-ABS.md similarity index 100% rename from python-abs.md rename to Python-Function-ABS.md