Archive of stories published by New Light Technologies, Inc. (NLT

Beyond assert

Last time, we built a factorial function in a test-driven style using Python’s assert statement:

def factorial(n):
if n < 0:
raise ValueError('Factorial of negative is undefined')
return n * factorial(n-1) if n else 1

Basic Negative Testing

In part one, we started writing a factorial function in the test-driven style. We depend on the humble “assert” statement to run our tests and we ended with this:

def factorial(n):
return n * factorial(n-1) if n else 1

These were the top 10 stories published by New Light Technologies, Inc. (NLT; you can also dive into yearly archives: 2019, 2020, 2021, and 2023.

About
New Light Technologies, Inc. (NLT
New Light Technologies (NLT) provides enterprise information solutions that combine Information Technology (IT) ingenuity and industry intelligence to drive high-performance results for our clients. We help commercial companies and governments at the federal, state, and local
More information
Tags
Editors