# Define a list of numbers
numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
# Initialize a variable to store the sum of even numbers
even_sum = 0
# Iterate through each number in the list
for num in numbers:
# Check if the number is even (divisible by 2)
if num % 2 == 0:
# If the number is even, add it to the even_sum
even_sum += num
# Print the list of numbers
print("List of numbers:", numbers)
# Print the sum of even numbers
print("Sum of even numbers:", even_sum)
import math
def worst_case_iterations(array_length):
# Calculate the worst-case number of iterations for a binary search
return math.ceil(math.log2(array_length))
# Array of length 20
array_length = 20
worst_case = worst_case_iterations(array_length)
print(f"Worst case iterations for an array of length {array_length}: {worst_case}")
- A