import math
import random


def exp(lambd):
    """
    Return a float from an exponential distribution with rate lambd.
    """
    
    # Approach 1:
    # return random.expovariate(lambd)
    
    # Approach 2:
    return -math.log(1 - random.random()) / lambd