Posts
A movie connection quiz in Python
Not so long time ago, I was living and working in Graz, Austria, and in my free time, I would regularly take part in a Pub Quiz.
Every Tuesday evening, me and my team the legendary Dudes, would gather for more than four hours among 40 other teams in the Office Pub, hang on Nick’s the quizmaster words, competing with the other teams for the top 5 places that gave money prizes, and at the same time chasing the 500 euros special blockbuster round prize, which eventually led us arguing with the quizmaster about his notoriously tricky questions, that every time drove us mad.
Posts
World's average country population and inspection paradox
Have you ever thought how much is the world’s average country population? And what does it say about the country you are living in or for the quality of life of the average person? All these questions are related to what we call the “Inspection Paradox” which we are going to illustrate here using Python.
First of all we need to find some data. For that purpose we could use wikipedia.
Posts
Lucy's Secret Number Puzzle
A good friend from Slovenia sent me this nice puzzle the other day:
Great riddle, but obviously a bad party if they discussed lucky numbers… J
You are at a party and overhear a conversation between Lucy and her friend.
In the conversation, Lucy mentions she has a secret number between 1 and 100.
She also confesses the following information:
“The number is uniquely describable by the answers to the following four questions:”
Posts
Avoid using an empty list as a default argument to a function
A very common error in Python is the use of an empty list as a default argument to a function. This is not the right way to do it and can cause unwanted behavior. See for example below:
def append_to_list(element, list_to_append=[]): list_to_append.append(element) return list_to_append >>> a = append_to_list(10) [10] >>> b = append_to_list(20) [10, 20] This is not the behavior we wanted! A new list is created once when the function is defined, and the same list is used in each successive call.