Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions banking_app/login.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# login.py - Placeholder for login functionality
import string
import hashlib

def login(username, password):
"""
Expand Down Expand Up @@ -33,3 +35,19 @@ def login(username, password):
- bool: `True` if login is successful, `False` if login fails, or raises a `ValueError` for invalid input.

"""

special_characters = "!@#$%^&*()_+-=[]{}|;:'\,.<>?/`~"
users = {"user1": hashlib.sha256("password123".encode()).hexdigest()}
if username == "" or password == "":
raise ValueError
if any(i in username for i in special_characters):
raise ValueError
if not username:
return False
if username in users:
stored_password = users[username]
return stored_password == hashlib.sha256(password.encode()).hexdigest()
return False


login("fjbnrf","furjg#")
2 changes: 1 addition & 1 deletion banking_app/user_management.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import csv
bimport csv

DATABASE_FILE = "banking_app/database.csv"

Expand Down
74 changes: 63 additions & 11 deletions functions_to_test.py
Original file line number Diff line number Diff line change
@@ -1,34 +1,81 @@
# Placeholder functions for Python basics, to be implemented later
import math


def add_numbers(a, b):
pass
return(a+b)


def find_maximum(a, b, c):
pass
list1 = [a,b,c]
return(max(list1))
print(find_maximum(4,5,6))

def is_palindrome(string):
pass
if type(string) == str:
string = string.lower()
string1 = string[::-1]
return(string==string1)
else:
raise TypeError

def count_word_occurrences(text, word):
pass
if type(word) == str and type(text) == str:
text1 = text.lower()
word1= word.lower()
word_count = text1.count(word1)
return (word_count)
else:
raise TypeError



def read_file_lines(filepath):
pass
with open(filepath,"r") as file:
lines = file.readlines()
return(lines)

def factorial(n):
pass
if n < 0:
raise ValueError
elif type(n) != int:
raise TypeError
from math import factorial as factors
return factors(n)


def is_prime(n):
pass
if n < 0 :
raise ValueError
elif n <= 1:
return False
elif type(n) != int :
raise TypeError
for i in range(2,n):
if n % i == 0:
return False
return True

def sort_numbers(numbers):
pass
for i in numbers:
if type(i) == str:
raise TypeError
return sorted(numbers)

def factorial(n):
pass
if n < 0:
return ""
elif type(n) != int:
raise TypeError
from math import factorial as factors
return factors(n)

def fibonacci(n):
pass
if n == 0:
return 0
elif n == 1:
return 1
return(fibonacci(n-1)+fibonacci(n-2))

def tower_of_hanoi(n, source, auxiliary, target):

Expand All @@ -52,7 +99,12 @@ def tower_of_hanoi(n, source, auxiliary, target):

class Person:
def __init__(self, name, age):
pass
if type(name) == str and type(age) == int:
self.name = name
self.age = age
return
else:
return TypeError


if __name__ == "__main__":
Expand Down