Category: Daily Python Puzzle

[Basics Computer Science] A Recursive Pathfinder Algorithm in Python

What is the output of this puzzle? *Intermediate Level* (solution below) A simple and effective way to grow your computer science skills is to master the basics. Knowing the basics sets apart the great coders from the merely intermediate ones. One such basic area in computer science is graph theory which we address in this…

Read MoreComment

A Case for Puzzle-based Learning Python

Overcome the Knowledge Gap The great teacher Sokrates delivered complex knowledge by asking a sequence of questions. Each question was building on answers to previous questions provided by the student. This more than 2400 year old teaching technique is still in wide-spread use today. A good teacher opens a gap between their’s and the learner’s…

Read MoreComment

Daily Data Science Puzzle: How to Get the Shape of a Numpy Matrix?

What is the output of this puzzle?     Numpy is a popular Python library for data science. The focus of the library is computations on arrays, vectors, and matrices. If you work with data, there is no way that you can avoid numpy. So learn it now and learn it well. We work on…

Read MoreComment

Daily Python Puzzle: How to Intersect two Sets in Python?

What is the output of this puzzle?     This puzzle is about two pieces of basic knowledge. The first piece of basic knowledge is what your mother always told you is true: vegetables and fruits are healthy. Eat 5 portions of vegetables and fruits per day or more and you will live longer. The…

Read MoreComment

Daily Python Puzzle: How to Find the Maximum in a Dictionary?

What is the output of this puzzle?     In this puzzle, we learn two things. First, we can retrieve the maximal element of a dictionary using the max function. Recap, a dictionary stores (key, value) pairs. In our example, the keys are strings with the names of five different foods such as ‘Eggs’. The…

Read MoreComment

How to Sort Dictionaries in Python?

What is the output of this puzzle?     In this puzzle, we show how to sort a dictionary not after the keys but after the values. Recap, a dictionary stores (key, value) pairs. In our example, the keys are strings with the names of five different foods such as ‘Eggs’. The dictionary maps each…

Read MoreComment

How to Boost your Logic Skills (Series)? The “in” and “is” Keywords.

What is the output of this puzzle?     This puzzle shows two new Python concepts: the ‘in’ and the ‘is’ keywords. Their intuitive use contributes heavily to the success of the Python programming language. The keyword ‘is’ takes two arguments A and B and is used in the form ‘A is B’. It evaluates…

Read MoreComment

Boost your Logic Skills Series

What is the output of this puzzle?     This puzzle shows the basic usage of boolean logic operators in Python. Boolean logic is crucial for coding. Try finding any real-world code project that does not use boolean logic. You will most certainly fail. Hence, to become a code master, you must master boolean logic…

Read MoreComment

The Python Map and Ord Functions – or How to Create Your Own Secret Language in Python

What is the output of this puzzle?     You already know that computers only operate on 0s and 1s. Every single character in a string is encoded as a sequence of 0s and 1s. Unicode is one such encoding that maps a bunch of zeros and ones (a binary ordinal value) to a symbol…

Read MoreComment

The Any Function or How to Analyze Tweets in Python

What is the output of this puzzle?     Both res1 and res2 store whether the variable crawled_text contains a word from the wordlist. res1: The map function checks for each element x in the wordlist whether x is an element of the split crawled_text. The default split function divides the string along the whitespaces….

Read MoreComment