Unit 1 Session 1 (Click for link to problem statements)
Understand what the interviewer is asking for by using test cases and questions about the problem.
Plan the solution with appropriate visualizations and pseudocode.
General Idea: Create a function that counts how many even numbers are in a list of integers.
1) Create a count variable with an initial count of zero
2) For each element in the list
a) Check if the number is even
b) If so, increment the count by 1
3) Return the count
⚠️ Common Mistakes
def count_evens(lst):
count = 0
for num in lst:
if num % 2 == 0:
count += 1
return count