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
27 changes: 27 additions & 0 deletions Primes.py
Original file line number Diff line number Diff line change
@@ -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)

31 changes: 31 additions & 0 deletions bonus.py
Original file line number Diff line number Diff line change
@@ -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"))