From 2782b99b732e3b09d25f9688bb6df6d8619e779c Mon Sep 17 00:00:00 2001 From: Havish <100441982+havishs9@users.noreply.github.com> Date: Sat, 15 Oct 2022 11:29:18 -0700 Subject: [PATCH 1/9] Create decimal_conversions.py --- maths/decimal_conversions.py | 56 ++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 maths/decimal_conversions.py diff --git a/maths/decimal_conversions.py b/maths/decimal_conversions.py new file mode 100644 index 000000000000..20177bf23722 --- /dev/null +++ b/maths/decimal_conversions.py @@ -0,0 +1,56 @@ +""" +References for Binary, Octal, and Hexadecimal Numbers + +https://en.wikipedia.org/wiki/Binary_number +https://en.wikipedia.org/wiki/Octal +https://en.wikipedia.org/wiki/Hexadecimal + +""" + + +def decimal_conversions(dec: int) -> int: + + binary = bin(dec)[2:] + octal = oct(dec)[2:] + hexadecimal = hex(dec)[2:] + + """ + bin(dec)[2:] -> Binary + oct(dec)[2:] -> Octal + hexadecimal = hex(dec)[2:] -> Hexadecimal + """ + + print(binary) + print(octal) + print(hexadecimal) + + """ + + Covert decimal number to binary, octal, and hexadecimal + >>> decimal_conversions(15) + + 1111 + 17 + f + + >>> decimal_conversions(1255) + + 10011100111 + 2347 + 4e7 + + >>> decimal_conversions(abcde) + + ValueError + + >>> decimal_conversions(-1) + + b1 + o1 + x1 + + """ + + +if __name__ == "__main__": + decimal_conversions(25) From 711bfa7e30d49ce288f2bcb2e64953b0ee677114 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 15 Oct 2022 18:31:26 +0000 Subject: [PATCH 2/9] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- maths/decimal_conversions.py | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/maths/decimal_conversions.py b/maths/decimal_conversions.py index 20177bf23722..669d361f7f34 100644 --- a/maths/decimal_conversions.py +++ b/maths/decimal_conversions.py @@ -6,26 +6,26 @@ https://en.wikipedia.org/wiki/Hexadecimal """ - + def decimal_conversions(dec: int) -> int: - binary = bin(dec)[2:] - octal = oct(dec)[2:] - hexadecimal = hex(dec)[2:] + binary = bin(dec)[2:] + octal = oct(dec)[2:] + hexadecimal = hex(dec)[2:] - """ + """ bin(dec)[2:] -> Binary oct(dec)[2:] -> Octal - hexadecimal = hex(dec)[2:] -> Hexadecimal - """ - - print(binary) - print(octal) - print(hexadecimal) - + hexadecimal = hex(dec)[2:] -> Hexadecimal """ + print(binary) + print(octal) + print(hexadecimal) + + """ + Covert decimal number to binary, octal, and hexadecimal >>> decimal_conversions(15) @@ -34,11 +34,11 @@ def decimal_conversions(dec: int) -> int: f >>> decimal_conversions(1255) - + 10011100111 2347 4e7 - + >>> decimal_conversions(abcde) ValueError @@ -48,9 +48,9 @@ def decimal_conversions(dec: int) -> int: b1 o1 x1 - + """ - + if __name__ == "__main__": - decimal_conversions(25) + decimal_conversions(25) From 69da5b22064890108376f6c7befec6c57dea0347 Mon Sep 17 00:00:00 2001 From: Havish <100441982+havishs9@users.noreply.github.com> Date: Mon, 24 Oct 2022 21:39:36 -0700 Subject: [PATCH 3/9] Create arc_length.py --- maths/arc_length.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 maths/arc_length.py diff --git a/maths/arc_length.py b/maths/arc_length.py new file mode 100644 index 000000000000..64893a79aceb --- /dev/null +++ b/maths/arc_length.py @@ -0,0 +1,19 @@ + + +import math +def arc(angle: int, rad: int) -> float: + """ + >>> arc(45, 5) + 3.9269908169872414 + >>> arc(120, 15) + 31.415926535897928 + """ + pi = math.pi + + return 2 * pi * rad * (angle / 360) + + +if __name__ == "__main__": + angle = 90 + rad = 10 + print(f"The length of the arc with radius {rad} and a central angle of {angle} degrees is {arc(angle, rad)}") From 4ee75669d0af00d744463f1efded69a714e65e27 Mon Sep 17 00:00:00 2001 From: Havish <100441982+havishs9@users.noreply.github.com> Date: Mon, 24 Oct 2022 21:40:08 -0700 Subject: [PATCH 4/9] Delete decimal_conversions.py --- maths/decimal_conversions.py | 56 ------------------------------------ 1 file changed, 56 deletions(-) delete mode 100644 maths/decimal_conversions.py diff --git a/maths/decimal_conversions.py b/maths/decimal_conversions.py deleted file mode 100644 index 669d361f7f34..000000000000 --- a/maths/decimal_conversions.py +++ /dev/null @@ -1,56 +0,0 @@ -""" -References for Binary, Octal, and Hexadecimal Numbers - -https://en.wikipedia.org/wiki/Binary_number -https://en.wikipedia.org/wiki/Octal -https://en.wikipedia.org/wiki/Hexadecimal - -""" - - -def decimal_conversions(dec: int) -> int: - - binary = bin(dec)[2:] - octal = oct(dec)[2:] - hexadecimal = hex(dec)[2:] - - """ - bin(dec)[2:] -> Binary - oct(dec)[2:] -> Octal - hexadecimal = hex(dec)[2:] -> Hexadecimal - """ - - print(binary) - print(octal) - print(hexadecimal) - - """ - - Covert decimal number to binary, octal, and hexadecimal - >>> decimal_conversions(15) - - 1111 - 17 - f - - >>> decimal_conversions(1255) - - 10011100111 - 2347 - 4e7 - - >>> decimal_conversions(abcde) - - ValueError - - >>> decimal_conversions(-1) - - b1 - o1 - x1 - - """ - - -if __name__ == "__main__": - decimal_conversions(25) From b2dd60daeac87d093268b2c139754d1c0d84abda Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 25 Oct 2022 04:43:17 +0000 Subject: [PATCH 5/9] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- maths/arc_length.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/maths/arc_length.py b/maths/arc_length.py index 64893a79aceb..fa3ff5e15300 100644 --- a/maths/arc_length.py +++ b/maths/arc_length.py @@ -1,6 +1,6 @@ - - import math + + def arc(angle: int, rad: int) -> float: """ >>> arc(45, 5) @@ -16,4 +16,6 @@ def arc(angle: int, rad: int) -> float: if __name__ == "__main__": angle = 90 rad = 10 - print(f"The length of the arc with radius {rad} and a central angle of {angle} degrees is {arc(angle, rad)}") + print( + f"The length of the arc with radius {rad} and a central angle of {angle} degrees is {arc(angle, rad)}" + ) From 2301ae904fd706d0d827b662fda8b4a8676346bf Mon Sep 17 00:00:00 2001 From: Chris O <46587501+ChrisO345@users.noreply.github.com> Date: Tue, 25 Oct 2022 18:29:09 +1300 Subject: [PATCH 6/9] Removed redundant statement, fixed line overflow --- maths/arc_length.py | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/maths/arc_length.py b/maths/arc_length.py index fa3ff5e15300..27f7f3ba29ef 100644 --- a/maths/arc_length.py +++ b/maths/arc_length.py @@ -1,4 +1,4 @@ -import math +from math import pi def arc(angle: int, rad: int) -> float: @@ -8,14 +8,8 @@ def arc(angle: int, rad: int) -> float: >>> arc(120, 15) 31.415926535897928 """ - pi = math.pi - return 2 * pi * rad * (angle / 360) if __name__ == "__main__": - angle = 90 - rad = 10 - print( - f"The length of the arc with radius {rad} and a central angle of {angle} degrees is {arc(angle, rad)}" - ) + print(arc(90, 10)) From 541db3fab0a966e4255f34e27667d9c6497d050c Mon Sep 17 00:00:00 2001 From: Chris O <46587501+ChrisO345@users.noreply.github.com> Date: Tue, 25 Oct 2022 19:03:51 +1300 Subject: [PATCH 7/9] Update arc_length.py Changed rad to radius as not to get confused with radians --- maths/arc_length.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/maths/arc_length.py b/maths/arc_length.py index 27f7f3ba29ef..dc8aace28510 100644 --- a/maths/arc_length.py +++ b/maths/arc_length.py @@ -1,14 +1,14 @@ from math import pi -def arc(angle: int, rad: int) -> float: +def arc(angle: int, radius: int) -> float: """ >>> arc(45, 5) 3.9269908169872414 >>> arc(120, 15) 31.415926535897928 """ - return 2 * pi * rad * (angle / 360) + return 2 * pi * radius * (angle / 360) if __name__ == "__main__": From ca8c30bb1956b17eb0de039cc8eb9cc7551fdec2 Mon Sep 17 00:00:00 2001 From: Chris O <46587501+ChrisO345@users.noreply.github.com> Date: Tue, 25 Oct 2022 19:09:31 +1300 Subject: [PATCH 8/9] Update arc_length.py --- maths/arc_length.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/maths/arc_length.py b/maths/arc_length.py index dc8aace28510..2349ebe3d5f5 100644 --- a/maths/arc_length.py +++ b/maths/arc_length.py @@ -1,7 +1,7 @@ from math import pi -def arc(angle: int, radius: int) -> float: +def arc_length(angle: int, radius: int) -> float: """ >>> arc(45, 5) 3.9269908169872414 @@ -12,4 +12,4 @@ def arc(angle: int, radius: int) -> float: if __name__ == "__main__": - print(arc(90, 10)) + print(arc_length(90, 10)) From 557ac5a042504d34b7d36fadf3448f5aee50bfb5 Mon Sep 17 00:00:00 2001 From: Chris O <46587501+ChrisO345@users.noreply.github.com> Date: Tue, 25 Oct 2022 20:58:25 +1300 Subject: [PATCH 9/9] Update arc_length.py --- maths/arc_length.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/maths/arc_length.py b/maths/arc_length.py index 2349ebe3d5f5..9e87ca38cc7d 100644 --- a/maths/arc_length.py +++ b/maths/arc_length.py @@ -3,9 +3,9 @@ def arc_length(angle: int, radius: int) -> float: """ - >>> arc(45, 5) + >>> arc_length(45, 5) 3.9269908169872414 - >>> arc(120, 15) + >>> arc_length(120, 15) 31.415926535897928 """ return 2 * pi * radius * (angle / 360)