Popcorn Hack 1

Write a function that will output a y value for y = 7(x+4)-6 when given an input of an x value.

def calculate_y(x):
    y = 7 * (x + 4) - 6
    return y

result = calculate_y(5)  # Let's use x = 5 as an example
print(f"The result of the calculation is: {result}")
The result of the calculation is: 57

Popcorn Hack 2

What will the code below print? My guess is 3.

number1 = 8
number2 = 3
number3 = (number1 // number2) + 1  # Integer division + 1
number4 = number3 * number2 * 2 - 15  # Multiplying by 2 and subtracting 15
print(f"New calculated number: {number4}")

New calculated number: 3

Popcorn Hack 3

Create a list of numbers that will all be tested for whether they are divisible by 3. If they are divisible by 3 the output will say that the number is divisible by 3 and if they aren’t divisible by 3 the output will be the remainder when the number is divided by 3.

def check_divisibility(numbers):
    for number in numbers:
        if number % 3 == 0 and number % 5 == 0:
            print(f"{number} is divisible by both 3 and 5")
        elif number % 3 == 0:
            print(f"{number} is divisible by 3")
        elif number % 5 == 0:
            print(f"{number} is divisible by 5")
        else:
            print(f"{number} is not divisible by 3 or 5, remainder by 3: {number % 3}, remainder by 5: {number % 5}")

numbers = [15, 20, 9, 11, 30]
check_divisibility(numbers)
15 is divisible by both 3 and 5
20 is divisible by 5
9 is divisible by 3
11 is not divisible by 3 or 5, remainder by 3: 2, remainder by 5: 1
30 is divisible by both 3 and 5