Python

Popcorn Hack #1

Dictionary = {"monkey": 1, "elephant": 2, "dog": 3, "whale": 4 }
print(Dictionary["whale"]) #any key will do
4

Popcorn Hack #2

first_number = int(input("Please Enter the First Number Here: "))
second_number = int(input("Please Enter the Second Number Here: "))
math_function = (input("Please Enter the function here:")) #Ex: +, -, *, /

if math_function == "+":
    print(first_number + second_number)
elif math_function == "-":
    print(first_number - second_number)
elif math_function == "*":
    print(first_number * second_number)
elif math_function == "/":
    print(first_number / second_number)
elif math_function == "**":
    print(first_number ** second_number)
else:
    print ("Invalid operation")
729

Popcorn Hack #3

def repeat_strings_in_list(strings, n): 
    result = [] # Creating array
    for string in strings:
        result.append(string * n)  # Repeating the string `n` times
    return result

string_list = ["cookies", "milk", "santa", "gifts"]
print(repeat_strings_in_list(string_list, 2))
['cookiescookies', 'milkmilk', 'santasanta', 'giftsgifts']

Popcorn Hack #4

def has_common_value(set1, set2):
    return any(value in set1 for value in set2)

set1 = {89, 95, 306, 524, 729}
set2 = {95, 542, 45}

if has_common_value(set1, set2):
    print(True)
else:
    print(False)
True