For my new book “Python Brain Games” (to appear in 2019, follow my email training program to get updates), I’m experimenting with a new code puzzle type: logics puzzles and brain games. It’s like Sudoku for coders! ??
Can you solve these five puzzles in five minutes? You can find the solutions at the end of this article…
# Puzzle 0 a, b, c, d = True, False, False, True if not a or not c: print('yes') else: print('python')
What’s the output of this logic puzzle?
# Puzzle 1 a, b, c, d = False, True, False, False if not d and b and d: if not a and not b: print('yes') elif a and c: print('yes') print('yes') elif b: if d: print('love') print('python') else: print('python')
What’s the output of this logic puzzle?
# Puzzle 2 a, b, c, d = False, True, True, True out = any([ c or b and not d, a and b or c or not b, b and d and a or c, d and not d or b or a, not c, not b or b, a, ]) print(out)
What’s the output of this logic puzzle?
# Puzzle 3 a, b = False, True out = (a and b and not a) or (not b) or (b and a) or (a and not a and not b) print(out)
What’s the output of this logic puzzle?
# Puzzle 4 a, b, c = True, True, True if b or not a or a: print('love') else: print('python')
What’s the output of this logic puzzle?
The Puzzle Solutions
# OUTPUT 0: ''' yes ''' # OUTPUT 1: ''' python ''' # OUTPUT 2: ''' True ''' # OUTPUT 3: ''' False ''' # OUTPUT 4: ''' love '''
What percentage of puzzles could you solve correctly? 80% or above is advanced intermediate level.

While working as a researcher in distributed systems, Dr. Christian Mayer found his love for teaching computer science students.
To help students reach higher levels of Python success, he founded the programming education website Finxter.com that has taught exponential skills to millions of coders worldwide. He’s the author of the best-selling programming books Python One-Liners (NoStarch 2020), The Art of Clean Code (NoStarch 2022), and The Book of Dash (NoStarch 2022). Chris also coauthored the Coffee Break Python series of self-published books. He’s a computer science enthusiast, freelancer, and owner of one of the top 10 largest Python blogs worldwide.
His passions are writing, reading, and coding. But his greatest passion is to serve aspiring coders through Finxter and help them to boost their skills. You can join his free email academy here.