From ff4612dd98365275f4e8a1fefc81871cb4e5006f Mon Sep 17 00:00:00 2001 From: AkshajV1309 <79909101+AkshajV1309@users.noreply.github.com> Date: Thu, 13 Oct 2022 21:20:38 +0530 Subject: [PATCH 1/9] Create norgate.py --- boolean_algebra/norgate.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 boolean_algebra/norgate.py diff --git a/boolean_algebra/norgate.py b/boolean_algebra/norgate.py new file mode 100644 index 000000000000..9688f6fe5d82 --- /dev/null +++ b/boolean_algebra/norgate.py @@ -0,0 +1,26 @@ +''' A NOR Gate is a logic gate in boolean algebra which results to false(0) + if any of the input is 1, and True(1) if both the inputs are 0. + Following is the truth table of an NOR Gate: + | Input 1 | Input 2 | Output | + | 0 | 0 | 1 | + | 0 | 1 | 0 | + | 1 | 0 | 0 | + | 1 | 1 | 0 | +''' +'''Following is the code implementation of the NOR Gate''' + +def nor_gate(input_1: int,input_2: int) -> int: + if input_1 == input_2 == 0: + return 1 + else: + return 0 + +if __name__== '__main__': + print('Truth Table of NOR Gate:') + print('| Input 1 |',' Input 2 |',' Output |') + print('| 0 |',' 0 | ',nor_gate(0,0),' |') + print('| 0 |',' 1 | ',nor_gate(0,1),' |') + print('| 1 |',' 0 | ',nor_gate(1,0),' |') + print('| 1 |',' 1 | ',nor_gate(1,1),' |') +'''Code provided by Akshaj Vishwanathan''' +'''Reference: https://www.geeksforgeeks.org/logic-gates-in-python/''' From 32a4f7dc72bc254c16e12eaaa17998d40548ce27 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 13 Oct 2022 15:54:43 +0000 Subject: [PATCH 2/9] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- boolean_algebra/norgate.py | 30 ++++++++++++++------------ web_programming/open_google_results.py | 8 +++---- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/boolean_algebra/norgate.py b/boolean_algebra/norgate.py index 9688f6fe5d82..dc9943f97d82 100644 --- a/boolean_algebra/norgate.py +++ b/boolean_algebra/norgate.py @@ -1,4 +1,4 @@ -''' A NOR Gate is a logic gate in boolean algebra which results to false(0) +""" A NOR Gate is a logic gate in boolean algebra which results to false(0) if any of the input is 1, and True(1) if both the inputs are 0. Following is the truth table of an NOR Gate: | Input 1 | Input 2 | Output | @@ -6,21 +6,23 @@ | 0 | 1 | 0 | | 1 | 0 | 0 | | 1 | 1 | 0 | -''' -'''Following is the code implementation of the NOR Gate''' +""" +"""Following is the code implementation of the NOR Gate""" -def nor_gate(input_1: int,input_2: int) -> int: + +def nor_gate(input_1: int, input_2: int) -> int: if input_1 == input_2 == 0: return 1 else: return 0 - -if __name__== '__main__': - print('Truth Table of NOR Gate:') - print('| Input 1 |',' Input 2 |',' Output |') - print('| 0 |',' 0 | ',nor_gate(0,0),' |') - print('| 0 |',' 1 | ',nor_gate(0,1),' |') - print('| 1 |',' 0 | ',nor_gate(1,0),' |') - print('| 1 |',' 1 | ',nor_gate(1,1),' |') -'''Code provided by Akshaj Vishwanathan''' -'''Reference: https://www.geeksforgeeks.org/logic-gates-in-python/''' + + +if __name__ == "__main__": + print("Truth Table of NOR Gate:") + print("| Input 1 |", " Input 2 |", " Output |") + print("| 0 |", " 0 | ", nor_gate(0, 0), " |") + print("| 0 |", " 1 | ", nor_gate(0, 1), " |") + print("| 1 |", " 0 | ", nor_gate(1, 0), " |") + print("| 1 |", " 1 | ", nor_gate(1, 1), " |") +"""Code provided by Akshaj Vishwanathan""" +"""Reference: https://www.geeksforgeeks.org/logic-gates-in-python/""" diff --git a/web_programming/open_google_results.py b/web_programming/open_google_results.py index 0e1dba8c5856..2685bf62114d 100644 --- a/web_programming/open_google_results.py +++ b/web_programming/open_google_results.py @@ -1,10 +1,10 @@ import webbrowser from sys import argv -from urllib.parse import quote, parse_qs -from fake_useragent import UserAgent +from urllib.parse import parse_qs, quote import requests from bs4 import BeautifulSoup +from fake_useragent import UserAgent if __name__ == "__main__": if len(argv) > 1: @@ -18,9 +18,7 @@ res = requests.get( url, - headers={ - "User-Agent": str(UserAgent().random) - }, + headers={"User-Agent": str(UserAgent().random)}, ) try: From 0542c536e750bc34cb43e2ef014edaad88272edd Mon Sep 17 00:00:00 2001 From: AkshajV1309 <79909101+AkshajV1309@users.noreply.github.com> Date: Thu, 13 Oct 2022 21:26:19 +0530 Subject: [PATCH 3/9] Create norgate.py --- boolean_algebra/norgate.py | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/boolean_algebra/norgate.py b/boolean_algebra/norgate.py index dc9943f97d82..f2a69c0cdae3 100644 --- a/boolean_algebra/norgate.py +++ b/boolean_algebra/norgate.py @@ -1,4 +1,4 @@ -""" A NOR Gate is a logic gate in boolean algebra which results to false(0) +''' A NOR Gate is a logic gate in boolean algebra which results to false(0) if any of the input is 1, and True(1) if both the inputs are 0. Following is the truth table of an NOR Gate: | Input 1 | Input 2 | Output | @@ -6,23 +6,24 @@ | 0 | 1 | 0 | | 1 | 0 | 0 | | 1 | 1 | 0 | -""" -"""Following is the code implementation of the NOR Gate""" +''' +'''Following is the code implementation of the NOR Gate''' - -def nor_gate(input_1: int, input_2: int) -> int: +def nor_gate(input_1: int,input_2: int) -> int: if input_1 == input_2 == 0: return 1 else: return 0 - - +def main() -> None: + print('Truth Table of NOR Gate:') + print('| Input 1 |',' Input 2 |',' Output |') + print('| 0 |',' 0 | ',nor_gate(0,0),' |') + print('| 0 |',' 1 | ',nor_gate(0,1),' |') + print('| 1 |',' 0 | ',nor_gate(1,0),' |') + print('| 1 |',' 1 | ',nor_gate(1,1),' |') if __name__ == "__main__": - print("Truth Table of NOR Gate:") - print("| Input 1 |", " Input 2 |", " Output |") - print("| 0 |", " 0 | ", nor_gate(0, 0), " |") - print("| 0 |", " 1 | ", nor_gate(0, 1), " |") - print("| 1 |", " 0 | ", nor_gate(1, 0), " |") - print("| 1 |", " 1 | ", nor_gate(1, 1), " |") -"""Code provided by Akshaj Vishwanathan""" -"""Reference: https://www.geeksforgeeks.org/logic-gates-in-python/""" + import doctest + doctest.testmod() + main() +'''Code provided by Akshaj Vishwanathan''' +'''Reference: https://www.geeksforgeeks.org/logic-gates-in-python/''' From 6749f953a4fc46398c7b9aa5ea88cc25fb09897f Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 13 Oct 2022 15:59:22 +0000 Subject: [PATCH 4/9] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- boolean_algebra/norgate.py | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/boolean_algebra/norgate.py b/boolean_algebra/norgate.py index f2a69c0cdae3..45ebbfe9a109 100644 --- a/boolean_algebra/norgate.py +++ b/boolean_algebra/norgate.py @@ -1,4 +1,4 @@ -''' A NOR Gate is a logic gate in boolean algebra which results to false(0) +""" A NOR Gate is a logic gate in boolean algebra which results to false(0) if any of the input is 1, and True(1) if both the inputs are 0. Following is the truth table of an NOR Gate: | Input 1 | Input 2 | Output | @@ -6,24 +6,30 @@ | 0 | 1 | 0 | | 1 | 0 | 0 | | 1 | 1 | 0 | -''' -'''Following is the code implementation of the NOR Gate''' +""" +"""Following is the code implementation of the NOR Gate""" -def nor_gate(input_1: int,input_2: int) -> int: + +def nor_gate(input_1: int, input_2: int) -> int: if input_1 == input_2 == 0: return 1 else: return 0 -def main() -> None: - print('Truth Table of NOR Gate:') - print('| Input 1 |',' Input 2 |',' Output |') - print('| 0 |',' 0 | ',nor_gate(0,0),' |') - print('| 0 |',' 1 | ',nor_gate(0,1),' |') - print('| 1 |',' 0 | ',nor_gate(1,0),' |') - print('| 1 |',' 1 | ',nor_gate(1,1),' |') + + +def main() -> None: + print("Truth Table of NOR Gate:") + print("| Input 1 |", " Input 2 |", " Output |") + print("| 0 |", " 0 | ", nor_gate(0, 0), " |") + print("| 0 |", " 1 | ", nor_gate(0, 1), " |") + print("| 1 |", " 0 | ", nor_gate(1, 0), " |") + print("| 1 |", " 1 | ", nor_gate(1, 1), " |") + + if __name__ == "__main__": import doctest + doctest.testmod() main() -'''Code provided by Akshaj Vishwanathan''' -'''Reference: https://www.geeksforgeeks.org/logic-gates-in-python/''' +"""Code provided by Akshaj Vishwanathan""" +"""Reference: https://www.geeksforgeeks.org/logic-gates-in-python/""" From 55b2d3114d23cb8f02e66cbc6ad306cbe3e842d0 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Thu, 13 Oct 2022 18:11:00 +0200 Subject: [PATCH 5/9] Update boolean_algebra/norgate.py --- boolean_algebra/norgate.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/boolean_algebra/norgate.py b/boolean_algebra/norgate.py index 45ebbfe9a109..f1d8a5f4678b 100644 --- a/boolean_algebra/norgate.py +++ b/boolean_algebra/norgate.py @@ -11,7 +11,21 @@ def nor_gate(input_1: int, input_2: int) -> int: - if input_1 == input_2 == 0: + """ + >>> nor_gate(0, 0) + 1 + >>> nor_gate(0, 1) + 0 + >>> nor_gate(1, 0) + 0 + >>> nor_gate(1, 1) + 0 + >>> nor_gate(0.0, 0.0) + 0 + >>> nor_gate(0, -7) + 0 + """ + return int(bool(input_1 == input_2 == 0)) return 1 else: return 0 From 12ded6c9e96cd75608b26ab93e9cb84b4ec1d477 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Thu, 13 Oct 2022 18:13:13 +0200 Subject: [PATCH 6/9] Update boolean_algebra/norgate.py --- boolean_algebra/norgate.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/boolean_algebra/norgate.py b/boolean_algebra/norgate.py index f1d8a5f4678b..e757855461be 100644 --- a/boolean_algebra/norgate.py +++ b/boolean_algebra/norgate.py @@ -26,9 +26,6 @@ def nor_gate(input_1: int, input_2: int) -> int: 0 """ return int(bool(input_1 == input_2 == 0)) - return 1 - else: - return 0 def main() -> None: From 4d1a2677e2990de51c1543c6720b863701bb96e2 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Thu, 13 Oct 2022 22:04:23 +0200 Subject: [PATCH 7/9] Update boolean_algebra/norgate.py --- boolean_algebra/norgate.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/boolean_algebra/norgate.py b/boolean_algebra/norgate.py index e757855461be..f7b65c47709d 100644 --- a/boolean_algebra/norgate.py +++ b/boolean_algebra/norgate.py @@ -23,7 +23,7 @@ def nor_gate(input_1: int, input_2: int) -> int: >>> nor_gate(0.0, 0.0) 0 >>> nor_gate(0, -7) - 0 + 1 """ return int(bool(input_1 == input_2 == 0)) From 05aaa962116b6deba4518270f499e160ac29d43e Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Thu, 13 Oct 2022 22:10:31 +0200 Subject: [PATCH 8/9] Update boolean_algebra/norgate.py --- boolean_algebra/norgate.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/boolean_algebra/norgate.py b/boolean_algebra/norgate.py index f7b65c47709d..b64d4d674e0b 100644 --- a/boolean_algebra/norgate.py +++ b/boolean_algebra/norgate.py @@ -21,7 +21,7 @@ def nor_gate(input_1: int, input_2: int) -> int: >>> nor_gate(1, 1) 0 >>> nor_gate(0.0, 0.0) - 0 + 1 >>> nor_gate(0, -7) 1 """ From 710addac926a3adb9bae48e4061cce4d5e217952 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Thu, 13 Oct 2022 22:18:04 +0200 Subject: [PATCH 9/9] Update boolean_algebra/norgate.py --- boolean_algebra/norgate.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/boolean_algebra/norgate.py b/boolean_algebra/norgate.py index b64d4d674e0b..82a1fb2e33e5 100644 --- a/boolean_algebra/norgate.py +++ b/boolean_algebra/norgate.py @@ -23,7 +23,7 @@ def nor_gate(input_1: int, input_2: int) -> int: >>> nor_gate(0.0, 0.0) 1 >>> nor_gate(0, -7) - 1 + 0 """ return int(bool(input_1 == input_2 == 0))