from random import randint
from subprocess import call


def wifi_down():
    call(['sudo', 'ip', 'link', 'set', 'dev', 'wlan0', 'down'])

def wifi_up():
    call(['sudo', 'ip', 'link', 'set', 'dev', 'wlan0', 'up'])

def generate_mac():
    mac_address = ':'.join([get_hex_pair() for _ in range(6)])
    return mac_address

def decimal_to_hex(n):
    """Takes a number from 0 to 15 and returns the hex digit."""
    return(hex(n)[2:])

def get_hex_pair():
    x = str(decimal_to_hex(randint(0, 15)))
    y = str(decimal_to_hex(randint(0, 15)))
    return x + y


from random import randint
from subprocess import call


def set_wifi(network_interface, status):
    """Turns off the wifi.
    
    Takes a string like 'wlan0' and a status like 'up' or 'down'.
    """
    if status in ['up', 'down']:
        call(['sudo', 'ip', 'link', 'set', 'dev', network_interface, status])

def dec_to_hex(n):
    """Takes a decimal number from 0 to 15 and returns the corresponding hex digit."""
    return(hex(n)[2:])

def get_hex_pair():
    """Returns a pair of hex digits as a string like: '5f'."""
    x = str(dec_to_hex(randint(0, 15)))
    y = str(dec_to_hex(randint(0, 15)))
    return x + y

def generate_mac():
    """Returns a randomly generated MAC address.
    
    Example format: '4a:bb:19:9f:3c:cf'.
    """
    mac_address = ':'.join([get_hex_pair() for _ in range(6)])
    return mac_address

def get_mac():
    pass

def set_mac(address):
    pass

set_wifi('wlan0', 'down')

set_wifi('wlan0', 'up')

Update code