Daily Python Puzzle

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

What is the output of this puzzle?   meal_1 = "Meat" meal_2 = "Flaxseeds" meal_3 = "Marshmallows" healthyFoods = ["Kale", "Apple", "Strawberry", "Banana", "Flaxseeds"] def isHealthy(food): return food in healthyFoods m_1 = isHealthy(meal_1) m_2 = isHealthy(meal_2) m_3 = isHealthy(meal_3) print((not m_1 or m_2) and (meal_2 is "Flaxseeds") and isHealthy("Kale"))   This puzzle shows two new …

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

The Any Function or How to Analyze Tweets in Python

What is the output of this puzzle?   wordlist = ["bitcoin", "cryptocurrency", "wallet"] crawled_text = ''' Research produced by the University of Cambridge estimates that in 2017, there are 2.9 to 5.8 million unique users using a cryptocurrency wallet, most of them using bitcoin. ''' s = crawled_text.split() res1 = True in map(lambda x: x …

The Any Function or How to Analyze Tweets in Python Read More »

Set Operations, Lambda Functions, and Who Dominates Social Networks

What is the output of this puzzle? # popular instagram accounts # (millions followers) inst = {"@instagram": 232, "@selenagomez": 133, "@victoriassecret": 59, "@cristiano": 120, "@beyonce": 111, "@nike": 76} # popular twitter accounts # (millions followers) twit = {"@cristiano": 69, "@barackobama": 100, "@ladygaga": 77, "@selenagomez": 56, "@realdonaldtrump": 48} inst_names = set(filter(lambda x: inst[x]>60, inst.keys())) twit_names = …

Set Operations, Lambda Functions, and Who Dominates Social Networks Read More »

Dictionaries and Unpacking Arguments in Python

Which function correctly sorts the list?   def f(val1=3, val2=4, val3=6): return val1 + val2 + val3 values = {"val1": 9, "val3":-1} print(f(**values))   Programming is about using lower-level functionality to create higher-level functionality. In general, any programming language is a collection of functions that in turn build upon functions provided by the operating system. …

Dictionaries and Unpacking Arguments in Python Read More »