diff --git a/src/verify.py b/src/verify.py new file mode 100644 index 0000000..4c7274e --- /dev/null +++ b/src/verify.py @@ -0,0 +1,10 @@ +array = [2,4,6,8,10,12,14,16,18,20] +def is_element_in_list(number : int) -> bool: + if number in array: + print("Numero presente") + return True + print("Numero non presente") + return False +if __name__ == "__main__": + n = int(input("Inserisci numero: ")) + is_element_in_list(n) diff --git a/tests/test_verify.py b/tests/test_verify.py new file mode 100644 index 0000000..7582fb9 --- /dev/null +++ b/tests/test_verify.py @@ -0,0 +1,16 @@ + +##Write a software that verifies if a number is present in a pre-defined array. +##Output example: +##Insert number 3 +##The number 3 is [not] present in the array. +## +success_test_array = [2,4,6,8,10,12,14,16,18,20] +fail_test_array = range(35,100) +import src.verify as verify + +def test_verify(): + for i in success_test_array: + assert verify.is_element_in_list(i) == True + for i in fail_test_array: + if i not in success_test_array: + assert verify.is_element_in_list(i) == False