diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..d56657a --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..4f4e885 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/python_projects.iml b/.idea/python_projects.iml new file mode 100644 index 0000000..d0876a7 --- /dev/null +++ b/.idea/python_projects.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/LinearSearch.py b/LinearSearch.py new file mode 100644 index 0000000..f027eaa --- /dev/null +++ b/LinearSearch.py @@ -0,0 +1,14 @@ +#Basic Linear Search + +# Defines function that searches through array +def linearsearch(arr, x): # Passes in target as x, and the array + for i in range(len(arr)): # Creates an index for length of array + if arr[i] == x: # Compares array value to searched value + return i # Returns index + return -1 + +arr = [1,2,3,4,5,6,7,8,9,10] # Defines array + +x = int(input("Enter a number between 1 and 10: ")) # Gets the user key value + +print("element found at index "+str(linearsearch(arr,x))) # Displays where the value is found \ No newline at end of file