Functional Python

Thu, Feb 21, 2019
P Python

Map map(function_to_apply, list_of_inputs) items = [1, 2, 3, 4, 5] squared = list(map(lambda x: x**2, items)) funcs = [multiply, add] for i in range(5): value = list(map(lambda x: x(i), funcs)) Filter number_list = range(-5, 5) less_than_zero = list(filter(lambda x: x < 0, number_list)) print(less_than_zero) #Output : [-5, -4, -3, -2, -1] Reduce from functools import Here, we obtain a reduction for our final product: product = reduce((lambda x, y: x * y), [1, 2, 3, 4]) # Output: 24

Python Basics

Sat, Dec 29, 2018
P Python

Foundations of Python programming This post will be about some of the most important syntax components in Python. This should read as a quick review (“cheatsheet”) for some of those things specific to the Python language that I need to refer back to every now and then. Integers and Floating point numbers Python is an untyped language, meaning you do not have to define the type of the variable. Integers are numbers without a decimal point and floating point numbers are numbers with a decimal point.