diff --git a/Primes.py b/Primes.py new file mode 100644 index 0000000..6e75ffd --- /dev/null +++ b/Primes.py @@ -0,0 +1,27 @@ + +def find_prime(start,end): + ''' + this takes 2 numbers, + check if they are 1 or less then 1 to exclude the nigative numbers, + then finds the prime numbers between them and prints them + + args: + start (int): the number to start from + end (int): the number to end at + + returns: + prints the prime numbers between start and end + + ''' + for n in range(start,end+1): + if n <= 1: + continue + else: + for lesser_then_root in range(2,int(n**0.5)+1): + if n % lesser_then_root == 0: + break + else: + print(n) + +find_prime(25,50) + \ No newline at end of file diff --git a/bonus.py b/bonus.py new file mode 100644 index 0000000..813e34c --- /dev/null +++ b/bonus.py @@ -0,0 +1,31 @@ +def new_string(old_string): + ''' + this checks if the string is a string, + then takes capital letters and adds a space before them and makes them small + + args: + old_string (str): the string to change + + returns: + finished_string (str): the string after the changes + + ''' + finished_string = " " + if type(old_string) != str: + finished_string = "This is not a string" + return finished_string + + for char in old_string: + if char.isupper(): + char = char.lower() + if finished_string[-1] == " ": + finished_string += char + else: + finished_string += " " + char + else: + finished_string += char + finished_string = finished_string[1:] + return finished_string + +print(new_string("HelloWorld There")) +