November 17, 2019
Python
A function is and object that is able to accept some sort of input, possibly modify it, and return some sort of output.
A lambda function is a one-line shorthand for function.
add_two = lambda my_input: my_input + 2
print (add_two(3))
>>> 5
check_if_A_grade = lambda grade: ‘Got an A!’ if grade > 90 else ‘Did not get an A.’
Lambda functions only work if we’re just doing a one-line command.
random.randint(5,8) would return any integer between 5 and 8, including 5 and 8.