Python Code Examples
Example Python code demonstrating various features.
Basic Function
Python
def greet(name: str) -> str:
"""
Greet a person by name.
Args:
name: The person's name
Returns:
A greeting message
"""
return f"Hello, {name}!"
Class Example
Python
class Calculator:
"""Simple calculator class."""
def add(self, a: float, b: float) -> float:
"""Add two numbers."""
return a + b
def subtract(self, a: float, b: float) -> float:
"""Subtract b from a."""
return a - b