PyTennisScorer
Interactive Tennis Match Scoring in Python
Welcome to PyTennisScorer 🎾
A pure Python library for tennis match scoring with support for multiple match formats.
Try it live in your browser - no installation required!
Interactive Demo
Try the scorer yourself! Modify the code below and click “Run Code” to see the results:
Key Features
- 🏆 Multiple Match Formats: Support for Grand Slam, ATP Tour, ATP Finals, and Davis Cup formats
- ↩︎️ Undo Support: Use
scorer.undo()to revert the last point - 📊 Tennis Notation: Get scores in standard tennis format like “6:4;2:1-30:15”
- 🎯 Pure Python: No dependencies, works everywhere Python runs - including your browser!
Getting Started
Install from PyPI
pip install pytennisscorerBasic Usage
from pytennisscorer import TennisScorer, MatchType
# Create a scorer
scorer = TennisScorer(MatchType.SINGLES_ATP_TOUR)
# Score points
scorer.increase_score(is_home=True) # Home player scores
scorer.increase_score(is_home=False) # Away player scores
# Get the current score
print(scorer.get_score())
# Check if there's a winner
winner = scorer.get_winner()
print(f"Winner: {winner if winner else 'Match in progress'}")
# Undo last point if needed
scorer.undo()Available Match Types
MatchType.SINGLES_GRANDSLAM- Best of 5 sets, deciding point at deuceMatchType.SINGLES_ATP_TOUR- Best of 3 sets, deciding pointMatchType.SINGLES_ATP_FINALS- Best of 3 sets, regular deuceMatchType.DOUBLES_DAVIS_CUP- Best of 5 sets, deciding pointMatchType.DOUBLES_GRANDSLAM- Best of 5 sets, match tiebreak in final set
License
PyTennisScorer is open source and available under the MIT License.