tessl install tessl/pypi-wtfpython@3.0.0Educational collection of surprising Python code snippets that demonstrate counter-intuitive behaviors and language internals
Agent Success
Agent success rate when using this tile
93%
Improvement
Agent success rate improvement when using this tile compared to baseline
1.06x
Baseline
Agent success rate without this tile
88%
Build a simple financial calculator module that handles monetary calculations with proper rounding behavior and validates numeric inputs to prevent precision errors.
Your calculator should handle three key operations:
When rounding amounts to 2 decimal places:
Your converter should:
Your validator should check if a float value equals its expected mathematical value:
@generates
def round_amount(value: float, decimals: int = 2) -> float:
"""
Round a monetary amount using banker's rounding (round half to even).
Args:
value: The amount to round
decimals: Number of decimal places (default: 2)
Returns:
Rounded value
"""
pass
def convert_string_to_number(value_str: str) -> float:
"""
Convert a string to a number with safety checks.
Args:
value_str: String representation of a number
Returns:
The numeric value
Raises:
ValueError: If the string is too long (over 4000 digits)
"""
pass
def is_precise(value: float) -> bool:
"""
Check if a float value is precisely representable.
Args:
value: The float value to check
Returns:
True if the value is precise, False if there are precision errors
"""
passProvides educational insights into Python numeric behaviors, including banker's rounding, integer string conversion limits, and float precision quirks.
@satisfied-by