From ac189be37a3ed670194def3959a20db00cbee033 Mon Sep 17 00:00:00 2001 From: Kashvi Bhatia Date: Mon, 22 Dec 2025 14:32:18 +0530 Subject: [PATCH 1/7] Refine Wheatstone Bridge explanation Updated docstring to provide a clearer explanation of the Wheatstone Bridge, its balance condition, and applications. --- electronics/wheatstone_bridge.py | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/electronics/wheatstone_bridge.py b/electronics/wheatstone_bridge.py index 3529a09339c4..38e7910e89a6 100644 --- a/electronics/wheatstone_bridge.py +++ b/electronics/wheatstone_bridge.py @@ -6,13 +6,22 @@ def wheatstone_solver( resistance_1: float, resistance_2: float, resistance_3: float ) -> float: """ - This function can calculate the unknown resistance in an wheatstone network, - given that the three other resistances in the network are known. - The formula to calculate the same is: - - --------------- - |Rx=(R2/R1)*R3| - --------------- + Wheatstone Bridge is an electrical circuit used to accurately measure + an unknown resistance by balancing two legs of a bridge circuit. + + The bridge is said to be balanced when no current flows + through the galvanometer connected between the midpoints + of the two voltage dividers. + Balance condition: + R1 / R2 = R3 / R4 + + Applications: + - Measurement of unknown resistance + - Strain gauge circuits + - Sensor calibration + This function can calculate the unknown resistance in an wheatstone + network, given that the three other resistances + in the network are known. Usage examples: >>> wheatstone_solver(resistance_1=2, resistance_2=4, resistance_3=5) From 278bc279c3c072daa98f4bef0ac69507df52bab3 Mon Sep 17 00:00:00 2001 From: Kashvi Bhatia Date: Mon, 22 Dec 2025 14:34:32 +0530 Subject: [PATCH 2/7] Update wheatstone_bridge.py From 48d3ad65dd90cf925c8402407c9bf0c48cf2e320 Mon Sep 17 00:00:00 2001 From: KashviBhatia Date: Fri, 26 Dec 2025 00:41:29 +0530 Subject: [PATCH 3/7] Add algorithm to count vowels and consonants in a string --- strings/count_vowels_consonants.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 strings/count_vowels_consonants.py diff --git a/strings/count_vowels_consonants.py b/strings/count_vowels_consonants.py new file mode 100644 index 000000000000..731c05b3b1e3 --- /dev/null +++ b/strings/count_vowels_consonants.py @@ -0,0 +1,29 @@ +def count_vowels_and_consonants(text: str) -> tuple[int, int]: + """ + Count the number of vowels and consonants in a given string. + + This function ignores non-alphabetic characters. + + Args: + text (str): Input string. + + Returns: + tuple[int, int]: A tuple containing (vowel_count, +consonant_count). + """ + vowels = set("aeiouAEIOU") + vowel_count = 0 + consonant_count = 0 + + for char in text: + if char.isalpha(): + if char in vowels: + vowel_count += 1 + else: + consonant_count += 1 + + return vowel_count, consonant_count + + +if _name_ == "_main_": + print(count_vowels_and_consonants("Hello World")) From 688371e58d96f6ae9256a8961f058f7a941937a1 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 25 Dec 2025 19:16:23 +0000 Subject: [PATCH 4/7] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- electronics/wheatstone_bridge.py | 6 +++--- strings/count_vowels_consonants.py | 14 +++++++------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/electronics/wheatstone_bridge.py b/electronics/wheatstone_bridge.py index 38e7910e89a6..9383ec7e5b01 100644 --- a/electronics/wheatstone_bridge.py +++ b/electronics/wheatstone_bridge.py @@ -9,8 +9,8 @@ def wheatstone_solver( Wheatstone Bridge is an electrical circuit used to accurately measure an unknown resistance by balancing two legs of a bridge circuit. - The bridge is said to be balanced when no current flows - through the galvanometer connected between the midpoints + The bridge is said to be balanced when no current flows + through the galvanometer connected between the midpoints of the two voltage dividers. Balance condition: R1 / R2 = R3 / R4 @@ -20,7 +20,7 @@ def wheatstone_solver( - Strain gauge circuits - Sensor calibration This function can calculate the unknown resistance in an wheatstone - network, given that the three other resistances + network, given that the three other resistances in the network are known. Usage examples: diff --git a/strings/count_vowels_consonants.py b/strings/count_vowels_consonants.py index 731c05b3b1e3..e7cdfecc9051 100644 --- a/strings/count_vowels_consonants.py +++ b/strings/count_vowels_consonants.py @@ -1,15 +1,15 @@ def count_vowels_and_consonants(text: str) -> tuple[int, int]: """ - Count the number of vowels and consonants in a given string. + Count the number of vowels and consonants in a given string. - This function ignores non-alphabetic characters. + This function ignores non-alphabetic characters. - Args: - text (str): Input string. + Args: + text (str): Input string. - Returns: - tuple[int, int]: A tuple containing (vowel_count, -consonant_count). + Returns: + tuple[int, int]: A tuple containing (vowel_count, + consonant_count). """ vowels = set("aeiouAEIOU") vowel_count = 0 From 838f73c7fc5870767bfb56950aaa449a57709900 Mon Sep 17 00:00:00 2001 From: Kashvi Bhatia Date: Fri, 26 Dec 2025 00:51:49 +0530 Subject: [PATCH 5/7] Remove test print statement from main section Removed test print statement for count_vowels_and_consonants function. --- strings/count_vowels_consonants.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/strings/count_vowels_consonants.py b/strings/count_vowels_consonants.py index e7cdfecc9051..3a58f620111b 100644 --- a/strings/count_vowels_consonants.py +++ b/strings/count_vowels_consonants.py @@ -25,5 +25,3 @@ def count_vowels_and_consonants(text: str) -> tuple[int, int]: return vowel_count, consonant_count -if _name_ == "_main_": - print(count_vowels_and_consonants("Hello World")) From 8697b953eb6a45ef52d7bde90c285e453d8f9326 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 25 Dec 2025 19:22:08 +0000 Subject: [PATCH 6/7] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- strings/count_vowels_consonants.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/strings/count_vowels_consonants.py b/strings/count_vowels_consonants.py index 3a58f620111b..3bab55403de9 100644 --- a/strings/count_vowels_consonants.py +++ b/strings/count_vowels_consonants.py @@ -23,5 +23,3 @@ def count_vowels_and_consonants(text: str) -> tuple[int, int]: consonant_count += 1 return vowel_count, consonant_count - - From 83058580025fdcbec08abc8cb68517553c986dfe Mon Sep 17 00:00:00 2001 From: Kashvi Bhatia Date: Fri, 26 Dec 2025 00:59:08 +0530 Subject: [PATCH 7/7] Enhance docstring with usage examples Added examples to the docstring for count_vowels_and_consonants function. --- strings/count_vowels_consonants.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/strings/count_vowels_consonants.py b/strings/count_vowels_consonants.py index 3bab55403de9..7486ee0cf9be 100644 --- a/strings/count_vowels_consonants.py +++ b/strings/count_vowels_consonants.py @@ -10,6 +10,15 @@ def count_vowels_and_consonants(text: str) -> tuple[int, int]: Returns: tuple[int, int]: A tuple containing (vowel_count, consonant_count). + Examples: + >>> count_vowels_and_consonants("Hello World") + (3, 7) + >>> count_vowels_and_consonants("AEIOU") + (5, 0) + >>> count_vowels_and_consonants("bcdf") + (0, 4) + >>> count_vowels_and_consonants("") + (0, 0) """ vowels = set("aeiouAEIOU") vowel_count = 0