""" Demonstrates how to use optional parameters in functions """ def optional(val, multiplier=1, adder=0): """ Multiply val by multiplier and add adder :param val: (int) the base value :param multiplier: (int) how much to multiply the base value :param adder: (int) how much to add to the product of val and multiplier :return: (int) val*multiplier + adder """ return val*multiplier + adder def list_of_nums(start, stop, step=1): """ Returns a list of numbers [start, start+step, start+step*2, ..., stop) :param start: (int) the first number in the list (inclusive) :param stop: (int) the last number in the list (exclusive) :param step: (int) the difference between two consecutive numbers in the list :return: (list of ints) a list of numbers [start, start+step, start+step*2, ..., stop) """ i = start r = [] while i < stop: r.append(i) i += step return r