Un-Cringing An is_even() Function in Python

Four ways to refactor code for determining even numbers.

Johnny B. Getgoode tweeted this screenshot of if-else statements.

Original Function in Python

1. Match & Case

2. Recursive Inner Function

3. Modulo Operator

4. Bitwise Operator

--

--

C.D. Reimer makes topical videos about comic cons, pop culture, Silicon Valley and technology on YouTube. https://www.youtube.com/cdreimer

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
C.D. Reimer

C.D. Reimer makes topical videos about comic cons, pop culture, Silicon Valley and technology on YouTube. https://www.youtube.com/cdreimer