Hello, checkiomates🐱👤!
In this edition, explore Python’s versatility and power. Discover the benefits of PyPy for optimizing performance, master the pathlib module for seamless file path operations, and refine your understanding of expressions vs. statements. Additionally, tackle a real-world programming mission: develop logic for a smart athletic watch that provides actionable exercise suggestions based on heart rate and oxygen saturation data.
💡TIP
We allow users to assign hotkeys to "Run Code", "Check Solution" and stop code. You may see current combinations on buttons and change them in editor menu. If you want to discover all CheckiO features, visit our tutorial. It's a longread, but it's worth it!
🏁MISSION
Sport Watch by freeman_lex -
A company is developing a new electronic watch for high-performance athletes. One of the features of the new watch is that it will measure the athlete's current heart rate (beats per minute) and current oxygen saturation. The watch will also calculate and store the athlete's resting heart rate.
The designers want the watch to warn the athlete that he or she must: slow down the pace of exercise if the current heart rate is more than three times the resting heart rate OR the current oxygen saturation is less than 95; increase the pace of exercise if the current heart rate is less than twice the resting heart rate AND the current oxygen saturation is greater than 97; maintain the pace of exercise if none of the above conditions occur.
pace_adjust(60, 190, 98) == -1 pace_adjust(70, 140, 92) == -1 pace_adjust(70, 130, 98) == 1
📖ARTICLES
Assessing PyPy Performance with π and Prime Numbers -
There is more than one implementation of the Python programming language, and CPython is by far the most widely used which, as the name implies, is written in the C programming language. Today’s focus is PyPy an implementation of Python written in…Python!
Does your Python code need to work with file paths? You should consider using pathlib. The author now uses pathlib for nearly all file-related code in Python, especially when he needs to construct or deconstruct file paths or ask questions of file paths.
Expression vs Statement in Python: What's the Difference? Quiz -
By working through this quiz, you’ll revisit the key differences between expressions and statements in Python, and how to use them effectively in your code.
👩💻CODE SHOT
How do you think, what the following code does?
def ????????(h: list[int]) -> int: result = min(h) * len(h) for w in range(1, len(h)): for i in range(len(h) - w + 1): result = max(result, min(h[i:i + w]) * w) return result
🙌 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! ⤵