Post image
Light Mode
Dark Mode
Python Powerhouse: Generators, Possibilities, Professional Sharing, and a Price Puzzle

Hello, checkiomates🐱‍👤!

This week's digest brings you a deep dive into the mechanics of Python generators, exploring their expressions and efficiency, alongside an inspiring overview of the diverse applications Python enables. We also cover the modern best practices for sharing your Python scripts like a pro, leveraging tools such as uv and the new PEP 723 standard for easy deployment. Beyond the code, we present a mission focused on price research, tasking you with analyzing alcohol and gasoline prices to uncover potential economic advantages based on a defined threshold.

💡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

Price Research by freeman_lex -

A journalist collected data on the prices of alcohol and gasoline in several states for a report on the economic advantage of filling up with alcohol. The rule used is that alcohol is considered advantageous when its price per liter is at most 70% of the price per liter of gasoline. Given the prices collected, your program must identify in which states it is more advantageous to fill up with alcohol. If it is not advantageous to use alcohol in any state, return a list with single element "*".

filter_regions([("AM", 7.0, 10.0), ("RS", 7.01, 10.0)]) == ["AM"]
filter_regions([("SP", 4.9, 5.8), ("RJ", 4.7, 5.7), ("PR", 4.6, 5.6)]) == ["*"]

📖 ARTICLES

Optimizing Python: Understanding Generator Mechanics, Expressions, and Efficiency -

Python generators provide an elegant mechanism for handling iteration, particularly for large datasets where traditional approaches may be memory-intensive. Unlike standard functions that compute and return all values at once, generators produce values on demand through the yield statement, enabling efficient memory usage and creating new possibilities for data processing workflows.

What Can You Do With Python? -

In this video course, you’ll find a set of guidelines that will help you start applying your Python skills to solve real-world problems. By the end, you’ll be able to answer the question, “What can you do with Python?”

Share Python Scripts Like a Pro -

Sharing single-file Python scripts with external dependencies is now easy thanks to uv and PEP 723, which enable embedding dependency metadata directly within scripts.

👩‍💻CODE SHOT

How do you think, what the following code does?

def ????????(structure):
    if isinstance(structure, int):
        return 0
    return 1 + max((????????(e) for e in structure), default=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! ⤵

Created: April 7, 2025, 4:55 p.m.
0
40
User avatar
freeman_lex