Hello, checkiomatesπ±βπ€!
Gently reminder: Prices Go Up September 1 β Lock In Your Rate Now!
This week's Python digest is an exercise in mastering complex execution models and applying clear logic to solve problems. We first unravel the world of asynchronous programming, exploring how asyncio handles concurrent tasks without blocking your program. Next, we grapple with a subtle puzzle from the "Python Koans," a thought-provoking challenge designed to deepen your understanding of the language's nuances. Finally, you can put your logical skills to the test with a practical mission: building a program to calculate employee prizes based on a bakery's point system.
π‘TIP
On Easy difficulty, each of the few starting stations is dedicated to a distinct data type. If you want to discover all CheckiO features, visit our tutorial. It's a longread, but it's worth it!
π MISSION
Bakery Sales by freeman_lex -
A bakery sells wholemeal breads, sweets and cakes. To encourage sales, the director announced prizes based on the number of products sold during the week, following a point system: each loaf of bread (b) is worth 1 point, each sweets pack (s) is worth 2 points and each cake (c) is worth 3 points. Depending on the total points accumulated, employees may receive a different reward. The challenge is to create a program that determines which award employees will receive based on the quantity of each product sold.
bakery_sales(100, 10, 4) == "S" bakery_sales(30, 45, 10) == "C" bakery_sales(3, 10, 5) == "N" bakery_sales(100, 0, 0) == "B"
π ARTICLES
Python's asyncio: A Hands-On Walkthrough -
Explore how Python asyncio works and when to use it. Follow hands-on examples to build efficient programs with coroutines and awaitable tasks.
asyncio: a library with too many sharp corners -
asyncio has a few gotchas and this post describes five different problems, including: cancellation, disappearing tasks, and more.
Understanding Late Binding in Python Closures -
In Python, a function is more than a list of commands, as we learnt in Koan 5. When a function is defined inside another, it becomes a closure, a small piece of code that remembers its parent's environment. This memory is powerful, but it's not a picture of the past. It's more like a window. It shows you the world as it is right now, not as it was when the window was first opened. This phenomenon is known as late binding.
π©βπ»CODE SHOT
What do you think the following code does?
checkio=lambda L:[e if i<2else sorted(L[i-2:i+1])[1]for i,e in enumerate(L)]
π Thanks for your attention! Hope to meet you at CheckiO, as well as at our Instagram and Twitter! We are really interested in your thoughts! Please, leave a comment below! ‡
