From 5f356cf37f53bf8d93eb1adf84ad16dd61509318 Mon Sep 17 00:00:00 2001 From: "m. mouse" Date: Wed, 18 Dec 2024 19:22:31 +0200 Subject: [PATCH 1/2] almost --- functions_to_test.py | 57 +++++++++++++++++++++++++++++++++++--------- 1 file changed, 46 insertions(+), 11 deletions(-) diff --git a/functions_to_test.py b/functions_to_test.py index 330fa02..be61c5b 100644 --- a/functions_to_test.py +++ b/functions_to_test.py @@ -1,34 +1,69 @@ # Placeholder functions for Python basics, to be implemented later def add_numbers(a, b): - pass + return a+b def find_maximum(a, b, c): - pass + if a > b and c: + return a + elif b > a and c: + return b + else: + return c + def is_palindrome(string): pass def count_word_occurrences(text, word): - pass + text = text.lower() + count=0 + for i in text: + if i == word: + count+=1 + return count def read_file_lines(filepath): - pass + try: + with open(filepath, "r") as file: + return file + + except FileNotFoundError: + return print("FILE NOT FOUND!") + + def factorial(n): pass def is_prime(n): - pass + if n > 1: + for i in range(2, (n//2)+1): + if (n % i) == 0: + return False + break + else: + return True + else: + return True + def sort_numbers(numbers): - pass - -def factorial(n): - pass - + n = sorted(numbers) + + if numbers.isdigit(): + return TypeError + else: + return n def fibonacci(n): - pass + if n == 1: + return 1 + + if n == 0: + return 0 + else: + return fibonacci(n-1) + fibonacci(n-2) + def tower_of_hanoi(n, source, auxiliary, target): From 674f4c1a855e82453d48ee5ae06e6497c6b80ccb Mon Sep 17 00:00:00 2001 From: "m. mouse" Date: Wed, 18 Dec 2024 19:55:07 +0200 Subject: [PATCH 2/2] try --- banking_app/login.py | 12 ++++++++++++ banking_app/signup.py | 29 +++++++++++++++++++++++++++++ banking_app/transaction.py | 17 +++++++++++++++++ functions_to_test.py | 2 +- 4 files changed, 59 insertions(+), 1 deletion(-) diff --git a/banking_app/login.py b/banking_app/login.py index 2bbab36..0a1bea6 100644 --- a/banking_app/login.py +++ b/banking_app/login.py @@ -1,6 +1,18 @@ # login.py - Placeholder for login functionality def login(username, password): + if username and password is None: + return False + elif username and password is None: + raise ValueError + + for i in username: + if i.isdecimal(): + raise ValueError + + if username not in database.cvs: + return (print("login fails")) + """ Handles the user login process by verifying the provided username and password. diff --git a/banking_app/signup.py b/banking_app/signup.py index a920e5b..82f0ec6 100644 --- a/banking_app/signup.py +++ b/banking_app/signup.py @@ -1,6 +1,35 @@ # signup.py - Placeholder for signup functionality def signup(username, password, email): + if username and password and email == None: + raise ValueError + + if username in Database_file.csv: + raise ValueError + + if len(password) >= 8 : + + special = False + lowerCase = False + upperCase = False + num = False + + for char in password: + if (char.isdigit()): + num = True + if (char.islower()): + lowerCase = True + if (char.isupper()): + upperCase = True + if (not char.isalnum() and char != ' '): + + special = True + + return num and lowerCase and upperCase and special + + return False + + """ Handles the user signup process by validating the provided username, password, and email. diff --git a/banking_app/transaction.py b/banking_app/transaction.py index a444e25..77945f3 100644 --- a/banking_app/transaction.py +++ b/banking_app/transaction.py @@ -1,6 +1,23 @@ # transaction.py - Placeholder for transaction functionality def transact(sender_account, receiver_account, amount): + if sender_account and receiver_account == None: + return False + + elif sender_account == receiver_account: + raise ValueError + + elif amount <= 0: + raise ValueError + + if sender_account and receiver_account not in database: + raise ValueError + + + if sender_account < amount: + raise ValueError + else: + sender_account -= amount """ Handles the transfer of funds between two user accounts. diff --git a/functions_to_test.py b/functions_to_test.py index be61c5b..7783862 100644 --- a/functions_to_test.py +++ b/functions_to_test.py @@ -51,7 +51,7 @@ def is_prime(n): def sort_numbers(numbers): n = sorted(numbers) - if numbers.isdigit(): + if (numbers.isdigit()): return TypeError else: return n