-
Discover New Features Of Python 3.13 And Implement Singleton With Decorators
Hello, checkiomates🐱👤!
In this digest we offer you a simple mission about Escher Symmetry and a few articles to discover new features of Python 3.13 and why Python is sweet and pythonic. Let's learn and have fun together at CheckiO!
💡TIP
You may click on any mission tag and see all missions, where this tag is present! If you want to discover all CheckiO features, visit our tutorial. It's a longread, but it's worth it!
🏁MISSION
Escher Symmetry by freeman_lex -
M. C. Escher was a Dutch graphic artist who created incredible illustrations which were inspired by mathematics. For example, he filled the canvas with self-similar objects, whose contours fit into themselves, creating very impressive geometric symmetries. See a very simple example of this idea in the following figure, which shows an object that is an orthogonal profile defined by a sequence of natural numbers representing the sequence of heights. We can take a copy of the object, rotate it 180 degrees and fit it perfectly into the original object, forming a rectangle. In this problem, you will be given the sequence of heights that define the profile and your program must decide whether the profile is Escher or not.
is_figure([1, 3, 2, 1, 3]) == True is_figure([1, 2, 2, 1]) == False is_figure([4, 4, 4, 4, 4, 4, 4, 4, 4]) == True
📖ARTICLES
Implementing a Python Singleton with Decorators -
In Python, a singleton is a design pattern that ensures a class has only one instance, and it provides a global point of access to that instance. This is useful when managing shared resources such as database connections, configuration objects, or logging systems where multiple instantiations would lead to inefficiencies or inconsistencies. In this blog post, we'll discuss a Python implementation of the singleton pattern using a decorator. We'll walk through the code and explain how it works, focusing on the _SingletonWrapper class and the singleton decorator function.
Python 3.13: Cool New Features for You to Try -
Python 3.13 was published on October 7, 2024. This new version is a major step forward for the language, although several of the biggest changes are happening under the hood and won’t be immediately visible to you. In a sense, Python 3.13 is laying the groundwork for some future improvements, especially to the language’s performance. As you read on, you’ll learn more about the background for this and dive into some new features that are fully available now.
Syntactic Sugar: Why Python Is Sweet and Pythonic Quiz -
Test your understanding of Python’s most common pieces of syntactic sugar and how they make your code more Pythonic and readable.
👩💻CODE SHOT
How do you think, what the following code does?
def ???????(data: list[int]) -> int: while len(data) > 1: data.sort() data.append(data.pop() - data.pop()) return data[0] if data else 0
🙌 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! ⤵
Welcome to CheckiO - games for coders where you can improve your codings skills.
The main idea behind these games is to give you the opportunity to learn by exchanging experience with the rest of the community. Every day we are trying to find interesting solutions for you to help you become a better coder.
Join the Game