Skip to the content.

3.5 popcorn and hw hacks

This is a collection of Sprint 2 Hacks.

3.5 Popcorn hack 1

def check_both_or_either(value1, value2):
    if value1 and value2:
        return "Both booleans are true."
    elif value1 or value2:
        return "At least one boolean is true."
    else:
        return "Both booleans are false."

bool1 = True
bool2 = False
print(check_both_or_either(bool1, bool2))
At least one boolean is true.

3.5 popcorn hack 2

number=int(input())
if number > 10:
    print("number is greater than 10")
else:
    print("number is less than 10")
number is greater than 10

3.5 popcorn hack 3

number=int(input())
def is_three_digits(num):
    return 100 <= num <= 999
print(is_three_digits(number))

True

3.5 hw hack

def truth_table():
    print("A     B     A AND B     A OR B     NOT A     NOT B")
    print("-----------------------------------------------------")
    for A in [True, False]:
        for B in [True, False]:
            and_result = A and B
            or_result = A or B
            not_A = not A
            not_B = not B
            print(f"{A}  {B}    {and_result}      {or_result}       {not_A}     {not_B}")
truth_table()
A     B     A AND B     A OR B     NOT A     NOT B
-----------------------------------------------------
True  True    True      True       False     False
True  False    False      True       False     True
False  True    False      True       True     False
False  False    False      False       True     True