diff options
author | Zhongheng Liu <z.liu@outlook.com.gr> | 2024-10-14 09:14:14 +0000 |
---|---|---|
committer | Zhongheng Liu <z.liu@outlook.com.gr> | 2024-10-14 09:14:14 +0000 |
commit | 99fcc543354860ed485b6ded092db4229adcaa16 (patch) | |
tree | afa6195662eafd9ec23dfabf9b20f1828a38cd5f | |
parent | d7ff01b21b4983da621cdb5746dfd6999b9b5ab7 (diff) | |
download | cs-y13-99fcc543354860ed485b6ded092db4229adcaa16.tar.gz cs-y13-99fcc543354860ed485b6ded092db4229adcaa16.tar.bz2 cs-y13-99fcc543354860ed485b6ded092db4229adcaa16.zip |
feat: lesson 3 content
-rw-r--r-- | lesson3.py | 23 |
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 |