# Define a list of numbers
numbers = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]

# Get the length of the list
list_length = len(numbers)

# Calculate the sum of the first half of the list
sum_first_half = sum(numbers[:list_length // 2])

# Print the result
print(sum_first_half)
import math

def worst_case_iterations(array_length):
    return math.ceil(math.log2(array_length))

# Calculate worst-case iterations for an array of length 20
worst_case_iterations_20 = worst_case_iterations(20)

print(f"Worst-case iterations for an array of length 20: {worst_case_iterations_20}")

Summary

3.12 Parts of a Procedure:

Procedures are named sets of instructions (also called methods or functions). Parameters are input values. A procedure call interrupts program flow, executing the procedure, and then continuing. Procedures simplify code by reusing instructions.

Popcorn Hack 1:

Explains return values and output parameters.

Popcorn Hack 2:

Create a Python program for generating multiplication tables.

Anatomy of Python Classes:

Class definition with attributes, methods, constructor, and self.