From 157bac102b888b3440a033838a8846ad1089fa0e Mon Sep 17 00:00:00 2001 From: Parth Bhatt Date: Sat, 21 Dec 2024 16:31:58 +0530 Subject: [PATCH 1/2] Add files via upload This is a full python project in which I have create a currency converter using python and API using APILayer. --- currencyconverter.py | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 currencyconverter.py diff --git a/currencyconverter.py b/currencyconverter.py new file mode 100644 index 0000000..8da3677 --- /dev/null +++ b/currencyconverter.py @@ -0,0 +1,39 @@ +import requests + +def convert_curr(): + init_currency = input("Enter the initial currency: ") + target_currency = input("Enter the target currency: ") + + while True: + try: + amount = float(input('Enter the amount: ')) + except: + print('The amount needs to be numeric') + continue + + if not amount > 0: + print('Amount needs to be greater than 0') + continue + else: + break + + url = f"https://api.apilayer.com/fixer/convert?to={target_currency}&from={init_currency}&amount={amount}" + + payload = {} + headers = { + "apikey": "DEFPqH61PuSInln1v9M5q9e7eO2f6zet" + } + + response = requests.request("GET", url, headers=headers, data=payload) + status_code = response.status_code + + if status_code != 200: + result = response.json() + print('Error response: ' + str(result)) + quit() + + result = response.json() + print('Conversion Result: ' + str(result['result'])) + +if __name__ == '__main__': + convert_curr() \ No newline at end of file From a5ae841235eaf9e23c8420ac488bed72a9cfec7c Mon Sep 17 00:00:00 2001 From: Parth Bhatt Date: Sat, 21 Dec 2024 17:05:26 +0530 Subject: [PATCH 2/2] Add files via upload This is a full python project which I've made that checks password strength. --- pswdchecker.py | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 pswdchecker.py diff --git a/pswdchecker.py b/pswdchecker.py new file mode 100644 index 0000000..4ce2772 --- /dev/null +++ b/pswdchecker.py @@ -0,0 +1,74 @@ +import string +import getpass + +def check_pwd(): + password = getpass.getpass("Enter Password: ") + strength = 0 + remarks = '' + lower_count = upper_count = num_count = wspace_count = special_count = 0 + + for char in list(password): + if char in string.ascii_lowercase: + lower_count += 1 + elif char in string.ascii_uppercase: + upper_count +=1 + elif char in string.digits: + num_count += 1 + elif char == ' ': + wspace_count +=1 + else: + special_count +=1 + + if lower_count >= 1: + strength +=1 + if upper_count >= 1: + strength +=1 + if num_count >= 1: + strength +=1 + if wspace_count>=1: + strength +=1 + if special_count>=1: + strength +=1 + + if strength == 1: + remarks = "Very Bad Password!!! Change ASAP" + elif strength == 2: + remarks = "Not A Good Password!!! Change ASAP" + elif strength ==3: + remarks = "It's a weak password, consider changing" + elif strength == 4: + remarks = "It's a hard password, but can be better" + elif strength == 5: + remarks = "A very strong password" + + print('Your password has: ') + print(f"{lower_count} lowercase characters") + print(f"{upper_count} uppercase characters") + print(f"{num_count} numeric characters") + print(f"{wspace_count} whitespace characters") + print(f"{special_count} special characters") + + print(f"Password Strength:{strength}") + print(f"Hint: {remarks}") + +def ask_pwd(another_pwd=False): + valid = False + if another_pwd: + choice=input('Do you want to enter another pwd (y/n): ') + else: + choice=input('Do you want to check pwd (y/n): ') + + while not valid: + if choice.lower() == 'y': + return True + elif choice.lower() == 'n': + return False + else: + print('Invalid, Try Again') + +if __name__ == '__main__': + print('+++ welcome to PWD checker +++') + ask_pw = ask_pwd() + while check_pwd: + check_pwd() + ask_pw = ask_pwd(True) \ No newline at end of file