Hello, checkiomates🐱👤!
This edition navigates key topics in Python development. Delve into the nuances of loop targets and their behavior, explore whether Python’s speed is truly a limitation, and test your knowledge with a deep dive into namespaces and scope. Plus, take on the challenge of creating a Shell Game simulation to sharpen your Python skills.
💡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
Shell Game by freeman_lex -
In the Shell game involving a coin and three opaque shells positioned in a line (A, B, and C), the "banker" player makes a series of moves to change the position of two shells, keeping the coin under the shell. Given the initial position of the coin and a sequence of moves made by the "banker", you must determine the final position of the coin. The moves are: 1 - swap A and B, 2 - swap B and C, and 3 - swap A and C.
shell_game("A", [1, 2, 3]) == "A" shell_game("C", [1, 2, 3, 3, 1, 1]) == "B" shell_game("B", [3]) == "B"
📖ARTICLES
Loop targets by Ned Batchelder -
Loop assignment allows you to assign to a dict item in a for loop. This post covers what that means and that it is no more costly than regular assignment.
My standard response when someone asks me how I deal with Python being such a slow language is that Python is by far the fastest to write, cleanest, more maintainable programming language I know, and that a bit of a runtime performance penalty is a small price to pay when I'm rewarded with significant productivity gains. I rarely feel Python slows me down, and on the other side I constantly marvel at how fast I code with it compared to other languages.
Namespaces and Scope in Python Quiz -
In this quiz, you’ll test your understanding of Python Namespaces and Scope. You’ll revisit how Python organizes symbolic names and objects in namespaces, when Python creates a new namespace, how namespaces are implemented, and how variable scope determines symbolic name visibility.
👩💻CODE SHOT
How do you think, what the following code does?
def ????????(recs: list[tuple[int]]) -> int: squares = set() for tlx, tly, brx, bry in recs: for x in range(tlx, brx): for y in range(tly, bry): squares.add((x, y)) return len(squares)
🙌 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! ⤵