Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ellenella - Ellen #421

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions count_zeros.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
def countZeros(A):
count = 0
#Iterate through the array
for i in A:
if i==0:
count+=1
return count

def test_countZeros():
# Test cases
assert countZeros([1, 0, 5, 6, 0, 2]) == 2, "First test case failed"
assert countZeros([0, 0]) == 2, "Second test case failed"
assert countZeros([1, 2]) == 0, "Third test case failed"
assert countZeros([]) == 0, "Forth test case failed"
assert countZeros([0]) == 1, "Fifth Test case failed"

print("All test cases passed!")

test_countZeros()