Post image
Light Mode
Dark Mode
Python's Edge: Code, Craft, & Challenges

Hello, checkiomates🐱‍👤!

This week in Python, we explore the practical applications of sets, delve into the art of "elliptical" or concise Python programming styles, and clarify the differences between instance, class, and static methods with a challenging quiz. To top it off, we present a mission focused on counting mountain peaks within a sequence of data, offering a chance to exercise your problem-solving skills.

💡TIP

At your profile, after clicking on big percent number of your progress, you may see module and methods you have already used in your shared solutions.
If you want to discover all CheckiO features, visit our tutorial. It's a longread, but it's worth it!

🏁 MISSION

Mountain Peaks by freeman_lex -

A computerized geographic information system represents the profile of a mountain through a sequence of integers, where no two consecutive numbers are the same. A peak is detected as three consecutive numbers where the middle number is bigger than the other two or two consecutive numbers at left/right end of a sequence where the left/rightmost number is bigger.
Your program must analyze this sequence to determine whether the mountain represented has more than one peak.

check_peaks([2, 3, 5, 6, 7, 5, 4, 2]) == False
check_peaks([2, 3, 6, 5, 4, 6, 3, 2]) == True
check_peaks([1, 2, 3, 2, 1]) == False

📖 ARTICLES

Practical uses of sets -

Sets are unordered collections of values that are great for removing duplicates, quick containment checks, and set operations.

Elliptical Python Programming -

This fun article shows how certain combinations of punctuation in Python can evaluate to integers, and as a result allow you to create some rather obfuscated code.

Python's Instance, Class, and Static Methods Demystified Quiz -

In this quiz, you’ll test your understanding of Instance, Class, and Static Methods in Python. By working through this quiz, you’ll revisit the differences between these methods and how to use them effectively in your Python code.

👩‍💻CODE SHOT

How do you think, what the following code does?

def ?????????(moves: str) -> int:

    t, f, r = 1, 2, 3
    for move in moves:
        t, f, r = {"N": f, "S": 7 - f, "W": r, "E": 7 - r}.get(move),\
                  {"N": 7 - t, "S": t}.get(move, f),\
                  {"W": 7 - t, "E": t}.get(move, r)

    return t

🙌 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 28, 2025, 4:08 p.m.
0
40
User avatar
freeman_lex