Making Choices

2. a. x and y
b. not x
c. x or y

4. Yes. If you try substituting all possible Boolean values for (light < 0.01), which we’ll abbreviate as L, and (temperature > 0.0) as T, you’ll find the following Boolean expressions are logically equivalent:

L T &nbsp;L != T&nbsp; &nbsp;L or T and not (L and T)&nbsp;
True True False False
True False True True
False True True True
False False False False

6.

def different(a, b):
    """ (number, number) -> bool

    Return True if a and b refer to the same values, or False, otherwise.

    >>> different(0, 1)
    True
    >>> different(1, 1)
    False
    """ 
    return a != b

8.

def convert_temperatures(t, source, target):
    """ (number, str, str) -> number

    Convert t from source temperature scale to target temperature scale
    and return the result.

    >>> convert_temperatures(0, 'Celsius', 'Kelvin')
    273.15
    >>> convert_temperatures(100, 'Celsius', 'Fahrenheit')
    212.0
    """ 
    if source == 'Kelvin':
        celsius = t - 273.15
    elif source == 'Celsius':
        celsius = t
    elif source == 'Fahrenheit':
        celsius = (t - 32) * 5 / 9
    elif source == 'Rankine':
        celsius = (t - 491.67) * 5 / 9
    elif source == 'Delisle':
        celsius = 100 - t * 2 / 3
    elif source == 'Newton':
        celsius = t * 100 / 33
    elif source == 'Reamur':
        celsius = t * 5 / 4
    elif source == 'Romer':
        celsius = (t - 7.5) * 40 / 21
    if target == 'Kelvin':
        return celsius + 273.15
    elif target == 'Celsius':
        return celsius
    elif target == 'Fahrenheit':
        return celsius * 9 / 5 + 32
    elif target == 'Rankine':
        return (celsius + 273.15) * 9 / 5
    elif target == 'Delisle':
        return (100 - celsius) * 3 / 2
    elif target == 'Newton':
        return celsius * 33 / 100
    elif target == 'Reamur':
        return celsius * 4 / 5
    elif target == 'Romer':
        return celsius * 21 / 40 + 7.5

10. a. It's acidic! b. It's acidic! c.

ph = float(input("Enter the ph level: "))
if ph < 7.0:
    print("It's acidic!")
if ph < 4.0:
    print("It's a strong acid!")