Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 3 additions & 34 deletions calculator.py
Original file line number Diff line number Diff line change
@@ -1,40 +1,9 @@
"""Calculator module for demo."""
import sqlite3


def add(a: int, b: int) -> int:
return int(a) + int(b)


def divide(a: float, b: float) -> float:
if b == 0:
raise ValueError("Cannot divide by zero")
return a / b


def get_user_score(db_path: str, username: str) -> int | None:
with sqlite3.connect(db_path) as conn:
cursor = conn.cursor()
result = cursor.execute(
"SELECT score FROM users WHERE username = ?",
(username,),
).fetchone()
return result[0] if result else None
"""Add two numbers."""
return a + b


def subtract(a: int, b: int) -> int:
"""Subtract b from a."""
return a - b


def multiply(a: int, b: int) -> int:
return a * b


def process_scores(scores: list[int]) -> dict:
if not scores:
return {}
return {
"total": sum(scores),
"average": sum(scores) / len(scores),
"max": max(scores),
}
Loading