summaryrefslogtreecommitdiff
path: root/lesson3.py
diff options
context:
space:
mode:
Diffstat (limited to 'lesson3.py')
-rw-r--r--lesson3.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/lesson3.py b/lesson3.py
new file mode 100644
index 0000000..90a8314
--- /dev/null
+++ b/lesson3.py
@@ -0,0 +1,23 @@
+import random
+def generate_test_data(length: int, _range: tuple):
+ arr = []
+ for i in range(length):
+ arr.append(random.randint(_range[0], _range[1]))
+ return arr
+def linsearch(myList: list, valueToFind: int):
+ mindex: int = len(myList) - 1
+ index: int = 0
+ found = False
+ while not found and index <= mindex:
+ if myList[index] == valueToFind:
+ found = True
+ index += 1
+ if found: print("VALUE FOUND!!!")
+ else: print("OH NO ITEM NOT FOUND IN LIST!!")
+def main():
+ arr = generate_test_data(100, (0, 1000))
+ print(arr)
+ inputFind = int(input("Value to find: "))
+ linsearch(arr, inputFind)
+if __name__ == "__main__":
+ main() \ No newline at end of file