From 4157f9464f9870131e16fe6e9c7e7fefa9dc26dc Mon Sep 17 00:00:00 2001 From: GAYATRI7272 Date: Thu, 1 Oct 2026 13:03:44 +0530 Subject: [PATCH 1/5] Fix EMA calculation for window size 1 --- financial/exponential_moving_average.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/financial/exponential_moving_average.py b/financial/exponential_moving_average.py index b56eb2712415..1722e9cbeb7c 100644 --- a/financial/exponential_moving_average.py +++ b/financial/exponential_moving_average.py @@ -19,7 +19,10 @@ def exponential_moving_average( Yields exponential moving averages of the given stock prices. >>> tuple(exponential_moving_average(iter([2, 5, 3, 8.2, 6, 9, 10]), 3)) (2, 3.5, 3.25, 5.725, 5.8625, 7.43125, 8.715625) + >>> tuple(exponential_moving_average(iter([10.0, 20.0, 30.0]), 1)) + (10.0, 20.0, 30.0) + :param stock_prices: A stream of stock prices :param window_size: The number of stock prices that will trigger a new calculation of the exponential average (window_size > 0) @@ -49,7 +52,7 @@ def exponential_moving_average( moving_average = 0.0 for i, stock_price in enumerate(stock_prices): - if i <= window_size: + if i < window_size: # Assigning simple moving average till the window_size for the first time # is reached moving_average = (moving_average + stock_price) * 0.5 if i else stock_price From 44cddc5789b67885af8c6edbc03298d0bd45ce1e Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 1 Oct 2026 09:07:25 +0000 Subject: [PATCH 2/5] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- ciphers/des_ecb.py | 37 +++++++++++++------------ financial/exponential_moving_average.py | 2 +- 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/ciphers/des_ecb.py b/ciphers/des_ecb.py index 4c904294a2d4..5a8a289adbe6 100644 --- a/ciphers/des_ecb.py +++ b/ciphers/des_ecb.py @@ -537,21 +537,22 @@ def decrypt(key: str, cipher_text: str) -> str: if mode not in ["e", "d", "k", "q"]: print("Invalid option. Please try again.") continue - if mode == "q": - break - elif mode == "k": - print(f"Generated key: {Des.generate_key()}") - elif mode == "e": - key = input("Enter the key: ").strip() - if len(key) != 16 and not all(char in "0123456789abcdef" for char in key): - print("Invalid key. Please try again.") - continue - input_string = input("Enter the string to encrypt: ").strip() - print(f"Encrypted string: {Des.encrypt(key, input_string)}") - elif mode == "d": - key = input("Enter the key: ").strip() - if len(key) != 16 and not all(char in "0123456789abcdef" for char in key): - print("Invalid key. Please try again.") - continue - cipher_text = input("Enter the cipher text to decrypt: ").strip() - print(f"Decrypted string: {Des.decrypt(key, cipher_text)}") + match mode: + case "q": + break + case "k": + print(f"Generated key: {Des.generate_key()}") + case "e": + key = input("Enter the key: ").strip() + if len(key) != 16 and not all(char in "0123456789abcdef" for char in key): + print("Invalid key. Please try again.") + continue + input_string = input("Enter the string to encrypt: ").strip() + print(f"Encrypted string: {Des.encrypt(key, input_string)}") + case "d": + key = input("Enter the key: ").strip() + if len(key) != 16 and not all(char in "0123456789abcdef" for char in key): + print("Invalid key. Please try again.") + continue + cipher_text = input("Enter the cipher text to decrypt: ").strip() + print(f"Decrypted string: {Des.decrypt(key, cipher_text)}") diff --git a/financial/exponential_moving_average.py b/financial/exponential_moving_average.py index 1722e9cbeb7c..85622295231d 100644 --- a/financial/exponential_moving_average.py +++ b/financial/exponential_moving_average.py @@ -22,7 +22,7 @@ def exponential_moving_average( >>> tuple(exponential_moving_average(iter([10.0, 20.0, 30.0]), 1)) (10.0, 20.0, 30.0) - + :param stock_prices: A stream of stock prices :param window_size: The number of stock prices that will trigger a new calculation of the exponential average (window_size > 0) From 85bfc12cc7e9cac108bde62a2ab162654d5cf383 Mon Sep 17 00:00:00 2001 From: GAYATRI7272 Date: Thu, 1 Oct 2026 14:50:30 +0530 Subject: [PATCH 3/5] Remove unrelated pre-commit change --- ciphers/des_ecb.py | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/ciphers/des_ecb.py b/ciphers/des_ecb.py index 5a8a289adbe6..4c904294a2d4 100644 --- a/ciphers/des_ecb.py +++ b/ciphers/des_ecb.py @@ -537,22 +537,21 @@ def decrypt(key: str, cipher_text: str) -> str: if mode not in ["e", "d", "k", "q"]: print("Invalid option. Please try again.") continue - match mode: - case "q": - break - case "k": - print(f"Generated key: {Des.generate_key()}") - case "e": - key = input("Enter the key: ").strip() - if len(key) != 16 and not all(char in "0123456789abcdef" for char in key): - print("Invalid key. Please try again.") - continue - input_string = input("Enter the string to encrypt: ").strip() - print(f"Encrypted string: {Des.encrypt(key, input_string)}") - case "d": - key = input("Enter the key: ").strip() - if len(key) != 16 and not all(char in "0123456789abcdef" for char in key): - print("Invalid key. Please try again.") - continue - cipher_text = input("Enter the cipher text to decrypt: ").strip() - print(f"Decrypted string: {Des.decrypt(key, cipher_text)}") + if mode == "q": + break + elif mode == "k": + print(f"Generated key: {Des.generate_key()}") + elif mode == "e": + key = input("Enter the key: ").strip() + if len(key) != 16 and not all(char in "0123456789abcdef" for char in key): + print("Invalid key. Please try again.") + continue + input_string = input("Enter the string to encrypt: ").strip() + print(f"Encrypted string: {Des.encrypt(key, input_string)}") + elif mode == "d": + key = input("Enter the key: ").strip() + if len(key) != 16 and not all(char in "0123456789abcdef" for char in key): + print("Invalid key. Please try again.") + continue + cipher_text = input("Enter the cipher text to decrypt: ").strip() + print(f"Decrypted string: {Des.decrypt(key, cipher_text)}") From 1c95f078ca64c0c3968365b1304b85ba182673f7 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 1 Oct 2026 09:44:15 +0000 Subject: [PATCH 4/5] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- ciphers/des_ecb.py | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/ciphers/des_ecb.py b/ciphers/des_ecb.py index 4c904294a2d4..5a8a289adbe6 100644 --- a/ciphers/des_ecb.py +++ b/ciphers/des_ecb.py @@ -537,21 +537,22 @@ def decrypt(key: str, cipher_text: str) -> str: if mode not in ["e", "d", "k", "q"]: print("Invalid option. Please try again.") continue - if mode == "q": - break - elif mode == "k": - print(f"Generated key: {Des.generate_key()}") - elif mode == "e": - key = input("Enter the key: ").strip() - if len(key) != 16 and not all(char in "0123456789abcdef" for char in key): - print("Invalid key. Please try again.") - continue - input_string = input("Enter the string to encrypt: ").strip() - print(f"Encrypted string: {Des.encrypt(key, input_string)}") - elif mode == "d": - key = input("Enter the key: ").strip() - if len(key) != 16 and not all(char in "0123456789abcdef" for char in key): - print("Invalid key. Please try again.") - continue - cipher_text = input("Enter the cipher text to decrypt: ").strip() - print(f"Decrypted string: {Des.decrypt(key, cipher_text)}") + match mode: + case "q": + break + case "k": + print(f"Generated key: {Des.generate_key()}") + case "e": + key = input("Enter the key: ").strip() + if len(key) != 16 and not all(char in "0123456789abcdef" for char in key): + print("Invalid key. Please try again.") + continue + input_string = input("Enter the string to encrypt: ").strip() + print(f"Encrypted string: {Des.encrypt(key, input_string)}") + case "d": + key = input("Enter the key: ").strip() + if len(key) != 16 and not all(char in "0123456789abcdef" for char in key): + print("Invalid key. Please try again.") + continue + cipher_text = input("Enter the cipher text to decrypt: ").strip() + print(f"Decrypted string: {Des.decrypt(key, cipher_text)}") From 260613cc3fff38ad33776f196e6e8cd58f8bb4df Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 1 Oct 2026 10:39:11 +0000 Subject: [PATCH 5/5] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- ciphers/des_ecb.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ciphers/des_ecb.py b/ciphers/des_ecb.py index 5a8a289adbe6..559aee9b764a 100644 --- a/ciphers/des_ecb.py +++ b/ciphers/des_ecb.py @@ -544,14 +544,18 @@ def decrypt(key: str, cipher_text: str) -> str: print(f"Generated key: {Des.generate_key()}") case "e": key = input("Enter the key: ").strip() - if len(key) != 16 and not all(char in "0123456789abcdef" for char in key): + if len(key) != 16 and not all( + char in "0123456789abcdef" for char in key + ): print("Invalid key. Please try again.") continue input_string = input("Enter the string to encrypt: ").strip() print(f"Encrypted string: {Des.encrypt(key, input_string)}") case "d": key = input("Enter the key: ").strip() - if len(key) != 16 and not all(char in "0123456789abcdef" for char in key): + if len(key) != 16 and not all( + char in "0123456789abcdef" for char in key + ): print("Invalid key. Please try again.") continue cipher_text = input("Enter the cipher text to decrypt: ").strip()