Are Python Lambda Functions All Greek To You?

Learn to Love Your Lambda! Lambda functions in python are simple one-line functions without a name (and therefore called an anonymous function) that can take many arguments but will only evaluate a single expression. Theyโ€™re fast, short, and simple and can help you write cleaner โ€˜more pythonicโ€™ code. If like me you wanted to learn … Read more

Python iter() — A Simple Illustrated Guide with Video

Python’s built-in iter() function returns an iterator for the given object. For example, iter([1, 2, 3]) creates an iterator for the list [1, 2, 3]. You can then iterate over all elements in the iterator, one element at a time, in a for or while loop such as: for x in iter([1, 2, 3]). Basic … Read more

Python memoryview() — Tame That Strange Beast!

The Python memoryview(arg) function returns a memoryview object of the given bytes or bytearray argument. This exposes the argument’s internal data (buffers) to help you access the data without intermediate copying. Syntax: memoryview(object) Arguments object Bytes or Bytearray object for which the memoryview should be returned Return Value memoryview Returns memoryview of the object. Python … Read more

NumPy arange(): A Simple Illustrated Guide

The np.arange() function appears in 21% of the 35 million Github repositories that use the NumPy library! This illustrated tutorial shows you the ins and outs of the NumPy arange function. So let’s get started! What’s the NumPy Arange Function? The np.arange([start,] stop[, step]) function creates a new NumPy array with evenly-spaced integers between start … Read more

Python Get Milliseconds

In this article we are going to look at how we can see time in milliseconds,ย  i.e. one thousandth (1000th) of a second, using Python. This could be for pure curiosity, benchmarking code or to getย  a very, very accurate time of day –ย  whatever the reason, the focus of the article is how to … Read more

Python vars() Function

Python’s built-in vars() function returns the __dict__ attribute of an object—a dictionary containing the object’s changeable attributes. Without argument, it returns the local symbol table similar to locals(). Python’s built-in vars() function returns a dictionary of name: value mappings of all the names defined in the local scope or the scope of the optional object … Read more

Python type() Function

Python’s built-in type() function has two purposes. First, you can pass an object as an argument to check the type of this object. Second, you can pass three arguments—name, bases, and dict—to create a new type object that can be used to create instances of this new type. Usage Learn by example! Here’s an example … Read more

They Use These 15+ Python Interview Questions To Fail You … (And What You Can Do About It)

Fear Your Coding Interview? This article shows you how to make your coding interview a success. General Tips to Prepare Your Interview Watch the following Instagram post and learn about popular Python interview questions (swipe left, swipe right): Sieh dir diesen Beitrag auf Instagram an [CHALLENGE] How many of the three questions can you answer? … Read more

Python min() — A Simple Illustrated Guide

The min() function returns the minimum of the provided arguments. As arguments, you can either pass a number of comma-separated values, or a single iterable. An optional key function argument allows you to customize the calculation of the minimum by explicitly defining the weight of each value in the iterable that is used as a … Read more

Python max() — A Simple Illustrated Guide

The max() function returns the maximum of the provided arguments. You can pass either an arbitrary number of values, comma-separated, or an iterable as arguments. An optional key function argument allows you to customize the calculation of the maximum by explicitly defining the weight of each value in the iterable that is used as a … Read more

How to Create a Sequence of Evenly Spaced Values [Vanilla Python & Numpy Linspace]

Problem: How to create a sequence of evenly-spaced values Using pure, vanilla Python, and Using NumPy’s linspace() method. Example: Given three arguments: start=10, stop=20, number_of_values=11. How do you create a sequence of 11 values x0, x1, …, x10 where two subsequent values xi and x(i-1) have the same distance for all i in {0, …, … Read more