Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
rioschala authored Jun 3, 2024
1 parent b29932a commit 225edc8
Showing 1 changed file with 64 additions and 0 deletions.
64 changes: 64 additions & 0 deletions library_IGCSE.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
def counting(array):
global counter
counter = 0
for i in array:
counter+=1
print(f"The array has {counter} elements.")
return counter

def totalling(array):
global total
total = 0
for i in array:
total+=i
print(f"The total of the elements array is {total}.")
return total

def linearsearch(array):
value=float(input("What number do you want to search for in your array?"))
found=False
index=0
while not found and index<len(array):
if array[index]==value:
found=True
else:
index+=1
if found == True:
print(f"Your number has been found at position {index}")
else:
print("Your value has not been found in the array.")

def bubblesort(array):
lengtharray = len(array)
for i in range(lengtharray):
swapped = False
for j in range(0, lengtharray-i-1):
if array[j]>array[j+1]:
array[j], array[j+1] = array[j+1], array[j]
swapped = True
print(array)
if not swapped:
break

def minimum(array):
minimum=array[0]
for i in array[1:]:
if i < minimum :
minimum=i
print(minimum)
print(f"The minimum value from {array} is {minimum}")

def maximum(array):
maximum=array[0]
for i in array[1:]:
if i > maximum :
maximum=i
print(maximum)
print(f"The maximum value from {array} is {maximum}")

def average(array):
totalling(array)
counting(array)
average=total/counter
print(f"The averega of this array {array} is {average}")

0 comments on commit 225edc8

Please sign in to comment.