From 9845f8f66ffc9fb19e17a37cc40c663a1ab840cc Mon Sep 17 00:00:00 2001 From: Samar upreti Date: Thu, 18 Jun 2026 03:38:18 -0700 Subject: [PATCH 1/7] Project _ Message_Encryption --- Projects/Message_Encryption.py | 65 ++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 Projects/Message_Encryption.py diff --git a/Projects/Message_Encryption.py b/Projects/Message_Encryption.py new file mode 100644 index 000000000000..50e70d96da29 --- /dev/null +++ b/Projects/Message_Encryption.py @@ -0,0 +1,65 @@ +import random as ra +import string as str + +def options(): + while True: + print("========== Welcome To Message Encryption ==========") + print("\t'1' For Encryption") + print("\t'2' For Decode") + try: + opt = int(input("Enter: ")) + if opt not in ("1","2",1,2): + print("Choose Number Between '1','2'") + if opt == 1: + encrypt() + elif opt == 2: + decode() + except ValueError: + print("Enter Numbers Only") + +def encrypt(): + x = input("Enter Your Message :") + + if len(x)<=3: + encrypt_key = input("Enter Your Key '1','4','7' :") + + with open("User_Key.txt","a+") as f: + f.write(f"{encrypt_key},{x}\n") + print(f"Successfully Encrypted: {x[::-1]}") + + encrypt_key = input("Enter Your Key '1','4','7' :") + + with open("User_Key.txt","a") as f: + f.write(f"{encrypt_key},{x}\n") + shift = x[1:] + x[0] + prefix = "".join(ra.choice(str.ascii_letters) for _ in range(3)) + suffix = "".join(ra.choice(str.ascii_letters) for _ in range(3)) + message = prefix + shift + suffix + message = message.strip() + print(f"Successfully Encrypted: {message}") + return encrypt_key + +def decode(): + with open("User_Key.txt", "r") as f: + user_message = input("Enter Message To Decode : ") + decode_key = input("Enter Your Key : ") + found = False + + for line in f: + encrypt_key, x = line.strip().split(",") + + if encrypt_key == decode_key: + if len(user_message) <= 3: + print(user_message[::-1]) + else: + x = user_message[3:-3] + x = x[-1] + x[:-1] + print(f"Message Decoded : {x}") + + found = True + break + + if not found: + print("Didn't Match :/") + +options() \ No newline at end of file From 35c17e8c7203065c550708ef7ee3b7d15d9a66e0 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 18 Jun 2026 10:43:21 +0000 Subject: [PATCH 2/7] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- Projects/Message_Encryption.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/Projects/Message_Encryption.py b/Projects/Message_Encryption.py index 50e70d96da29..822de1b2275d 100644 --- a/Projects/Message_Encryption.py +++ b/Projects/Message_Encryption.py @@ -1,6 +1,7 @@ import random as ra import string as str + def options(): while True: print("========== Welcome To Message Encryption ==========") @@ -8,7 +9,7 @@ def options(): print("\t'2' For Decode") try: opt = int(input("Enter: ")) - if opt not in ("1","2",1,2): + if opt not in ("1", "2", 1, 2): print("Choose Number Between '1','2'") if opt == 1: encrypt() @@ -17,20 +18,21 @@ def options(): except ValueError: print("Enter Numbers Only") + def encrypt(): x = input("Enter Your Message :") - if len(x)<=3: + if len(x) <= 3: encrypt_key = input("Enter Your Key '1','4','7' :") - with open("User_Key.txt","a+") as f: + with open("User_Key.txt", "a+") as f: f.write(f"{encrypt_key},{x}\n") print(f"Successfully Encrypted: {x[::-1]}") encrypt_key = input("Enter Your Key '1','4','7' :") - - with open("User_Key.txt","a") as f: - f.write(f"{encrypt_key},{x}\n") + + with open("User_Key.txt", "a") as f: + f.write(f"{encrypt_key},{x}\n") shift = x[1:] + x[0] prefix = "".join(ra.choice(str.ascii_letters) for _ in range(3)) suffix = "".join(ra.choice(str.ascii_letters) for _ in range(3)) @@ -39,6 +41,7 @@ def encrypt(): print(f"Successfully Encrypted: {message}") return encrypt_key + def decode(): with open("User_Key.txt", "r") as f: user_message = input("Enter Message To Decode : ") @@ -62,4 +65,5 @@ def decode(): if not found: print("Didn't Match :/") -options() \ No newline at end of file + +options() From a15dac9469071f8c54d1ba227567a5201fdaa1fd Mon Sep 17 00:00:00 2001 From: Samar upreti Date: Tue, 23 Jun 2026 05:07:04 -0700 Subject: [PATCH 3/7] improve unexpected error, inhance the best evolution --- genetic_algorithm/basic_string.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/genetic_algorithm/basic_string.py b/genetic_algorithm/basic_string.py index b75491d9a949..c483d18622ad 100644 --- a/genetic_algorithm/basic_string.py +++ b/genetic_algorithm/basic_string.py @@ -54,7 +54,7 @@ def mutate(child: str, genes: list[str]) -> str: """ child_list = list(child) if random.uniform(0, 1) < MUTATION_PROBABILITY: - child_list[random.randint(0, len(child)) - 1] = random.choice(genes) + random.randint(0, len(child)-1) = random.choice(genes) return "".join(child_list) @@ -175,7 +175,10 @@ def basic(target: str, genes: list[str], debug: bool = True) -> tuple[int, int, # Flush the old population, keeping some of the best evolutions. # Keeping this avoid regression of evolution. - population_best = population[: int(N_POPULATION / 3)] + population_best = [ + item[0] + for item in population_score[: int(N_POPULATION / 3)] + ] population.clear() population.extend(population_best) # Normalize population score to be between 0 and 1. From 4c06bd42b1714904ea97b803d121d2af31139865 Mon Sep 17 00:00:00 2001 From: Samar upreti Date: Tue, 23 Jun 2026 05:12:02 -0700 Subject: [PATCH 4/7] improve --- genetic_algorithm/basic_string.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/genetic_algorithm/basic_string.py b/genetic_algorithm/basic_string.py index c483d18622ad..4bcddf2360db 100644 --- a/genetic_algorithm/basic_string.py +++ b/genetic_algorithm/basic_string.py @@ -54,7 +54,9 @@ def mutate(child: str, genes: list[str]) -> str: """ child_list = list(child) if random.uniform(0, 1) < MUTATION_PROBABILITY: - random.randint(0, len(child)-1) = random.choice(genes) + random_index = random.randint(0, len(child)-1) + child_list[random_index] = random.choice(genes) + return "".join(child_list) From 16142710bec8086d6f2ccf2ada0ec2197029c9bf Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 23 Jun 2026 12:12:22 +0000 Subject: [PATCH 5/7] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- genetic_algorithm/basic_string.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/genetic_algorithm/basic_string.py b/genetic_algorithm/basic_string.py index 4bcddf2360db..fba63280c59f 100644 --- a/genetic_algorithm/basic_string.py +++ b/genetic_algorithm/basic_string.py @@ -54,9 +54,9 @@ def mutate(child: str, genes: list[str]) -> str: """ child_list = list(child) if random.uniform(0, 1) < MUTATION_PROBABILITY: - random_index = random.randint(0, len(child)-1) + random_index = random.randint(0, len(child) - 1) child_list[random_index] = random.choice(genes) - + return "".join(child_list) @@ -178,8 +178,7 @@ def basic(target: str, genes: list[str], debug: bool = True) -> tuple[int, int, # Flush the old population, keeping some of the best evolutions. # Keeping this avoid regression of evolution. population_best = [ - item[0] - for item in population_score[: int(N_POPULATION / 3)] + item[0] for item in population_score[: int(N_POPULATION / 3)] ] population.clear() population.extend(population_best) From 50f158477fd67614eabe2d47ffc90f5eb5f0e987 Mon Sep 17 00:00:00 2001 From: Samar upreti Date: Fri, 3 Jul 2026 14:28:16 +0530 Subject: [PATCH 6/7] (it Fatches new Articles as per user request) --- Projects/News.py | 78 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 Projects/News.py diff --git a/Projects/News.py b/Projects/News.py new file mode 100644 index 000000000000..0c8e50fea4f8 --- /dev/null +++ b/Projects/News.py @@ -0,0 +1,78 @@ +import requests +import sys + +def options(): + + print("-"*5,"Welcome To Daily News","-"*5) + print("Enter 1 For Headlines") + print("Enter 2 For Topic's") + print("Enter 3 For Geting News From Your API :)") + print("Enter 4 For Exit") + + while True: + + try: + choose = int(input("Choose :")) + match choose: + + case 1: + return Fatch_News() + case 2: + return search() + case 3: + return Fatch_Key() + case 4: + return Exit() + + except ValueError: + print("Enter Numbers Only") + +def Fatch_Key(): + + user_key = input("Enter Your API Key :") + return Fatch_News(user_key) + +def search(): + pass + +def Fatch_News(user_key = ""): #Enter Your API Key Heare + + url = f"https://newsapi.org/v2/everything?q=keyword&apiKey={user_key}" + request = requests.get(url) + data = request.json() + + news = [] + + for article in data["articles"]: + + news.append({ + "Title" : article["title"], + "Author" : article["author"], + "Description" : article["description"] + }) + + return news + + +def Exit(): + + print("Thanks For Using PDF Tool Kit :)") + sys.exit() + +#Run These Command To Get Info About Type Of Data We Are Dealing With +def Data_Info(): + + '''Tell Abut Type Of Data We Are Grtting From URL''' + + url = "https://newsapi.org/v2/everything?q=keyword&apiKey=6495169f47154cfd83e9ac94ed500b0a" + request = requests.get(url) + + data = request.json() + + print(type(data)) + print(data.keys()) + print(data['articles'][0].keys()) + +if __name__ == "__main__": + options() + \ No newline at end of file From 1430a6292c5b794830e90ae6fc5fa577ec3b1f39 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 3 Jul 2026 08:58:37 +0000 Subject: [PATCH 7/7] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- Projects/News.py | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/Projects/News.py b/Projects/News.py index 0c8e50fea4f8..5cedad632546 100644 --- a/Projects/News.py +++ b/Projects/News.py @@ -1,20 +1,19 @@ import requests import sys + def options(): - print("-"*5,"Welcome To Daily News","-"*5) + print("-" * 5, "Welcome To Daily News", "-" * 5) print("Enter 1 For Headlines") print("Enter 2 For Topic's") print("Enter 3 For Geting News From Your API :)") print("Enter 4 For Exit") while True: - try: choose = int(input("Choose :")) match choose: - case 1: return Fatch_News() case 2: @@ -23,34 +22,38 @@ def options(): return Fatch_Key() case 4: return Exit() - + except ValueError: print("Enter Numbers Only") + def Fatch_Key(): user_key = input("Enter Your API Key :") return Fatch_News(user_key) + def search(): pass -def Fatch_News(user_key = ""): #Enter Your API Key Heare + +def Fatch_News(user_key=""): # Enter Your API Key Heare url = f"https://newsapi.org/v2/everything?q=keyword&apiKey={user_key}" request = requests.get(url) data = request.json() news = [] - + for article in data["articles"]: + news.append( + { + "Title": article["title"], + "Author": article["author"], + "Description": article["description"], + } + ) - news.append({ - "Title" : article["title"], - "Author" : article["author"], - "Description" : article["description"] - }) - return news @@ -59,10 +62,10 @@ def Exit(): print("Thanks For Using PDF Tool Kit :)") sys.exit() -#Run These Command To Get Info About Type Of Data We Are Dealing With -def Data_Info(): - '''Tell Abut Type Of Data We Are Grtting From URL''' +# Run These Command To Get Info About Type Of Data We Are Dealing With +def Data_Info(): + """Tell Abut Type Of Data We Are Grtting From URL""" url = "https://newsapi.org/v2/everything?q=keyword&apiKey=6495169f47154cfd83e9ac94ed500b0a" request = requests.get(url) @@ -71,8 +74,8 @@ def Data_Info(): print(type(data)) print(data.keys()) - print(data['articles'][0].keys()) + print(data["articles"][0].keys()) + if __name__ == "__main__": - options() - \ No newline at end of file + options()