##QUESTION 1

# Create a list of numbers
numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9]

# Count how many numbers are in the list
number_of_numbers = len(numbers)

# Get the first number from the list
first_number = numbers[0]

# Get the last number from the list
last_number = numbers[-1]

# Pick a group of numbers from the list
chosen_numbers = numbers[2:5]  # These are numbers at positions 2, 3, and 4

# Add a new number to the list
numbers.append(10)

# Remove the number 5 from the list
numbers.remove(5)

# Put the numbers in order from small to big
numbers.sort()

# Flip the order of the numbers
numbers.reverse()

# Check if the number 7 is in the list
is_7_present = 7 in numbers

# Find where the number 6 is in the list
position_of_6 = numbers.index(6)

# Count how many times the number 6 appears in the list
count_of_6 = numbers.count(6)

# Show the results
print("Here are the numbers:", numbers)
print("There are this many numbers in the list:", number_of_numbers)
print("The first number is:", first_number)
print("The last number is:", last_number)
print("This group of numbers was chosen:", chosen_numbers)
print("Is the number 7 in the list?", is_7_present)
print("The number 6 is at position:", position_of_6)
print("The number 6 appears this many times:", count_of_6)

##QUESTION 2

import math

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

array_length = 20
worst_case_iterations = calculate_worst_case_binary_search_iterations(array_length)

print(f"For an array of length {array_length}, the worst-case number of iterations in a binary search is {worst_case_iterations}.")

##QUESTION 3

##Answer will be A because it is the only option that multiplies the values by 2

Here are the numbers: [10, 9, 8, 7, 6, 4, 3, 2, 1]
There are this many numbers in the list: 9
The first number is: 1
The last number is: 9
This group of numbers was chosen: [3, 4, 5]
Is the number 7 in the list? True
The number 6 is at position: 4
The number 6 appears this many times: 1
For an array of length 20, the worst-case number of iterations in a binary search is 5.