Thank you for your interest in contributing to the Student Utility Library! This guide will help you get started with making your first contribution.
Look through the source code for functions marked with:
# TODO: Implement this functionStart with simpler functions and gradually work on more complex ones.
Start Here (Easy):
src/string_utils/:reverse_string(),count_words(),capitalize_words()src/math_utils/:factorial(),is_prime(),mean()
Intermediate:
src/string_utils/:is_palindrome(),count_characters(),is_anagram()src/math_utils/:gcd(),lcm(),fibonacci(),median()src/file_utils/:read_file(),write_file(),count_lines()
Advanced:
src/data_structures/: All classes (Stack,Queue,LinkedList, etc.)src/algorithms/: Sorting and searching algorithmssrc/file_utils/: CSV/JSON handling functions
-
Read the Documentation: Each function has detailed docstrings explaining:
- What the function should do
- Input parameters and their types
- Expected return values
- Usage examples
- Implementation hints
-
Understand the Tests: Look at the corresponding test file in
tests/to see what behavior is expected. -
Implement the Function: Replace the
passstatement with your implementation. -
Test Your Code: Run the specific tests for your function:
python -m pytest tests/test_string_utils.py::TestStringUtils::test_reverse_string -v
-
Run All Tests: Make sure you didn't break anything:
python -m pytest tests/ -v
-
Install Dependencies:
pip install -r requirements.txt
-
Run Tests:
python -m pytest tests/ -v
-
Try Examples:
python examples/basic_usage.py
- Follow PEP 8 style guidelines
- Use meaningful variable names
- Add type hints to function parameters and return values
- Include docstrings for any new functions you create
Here's how you might implement the reverse_string function:
def reverse_string(text: str) -> str:
"""
Reverse the given string.
Args:
text (str): The input string to reverse
Returns:
str: The reversed string
"""
# Method 1: Using string slicing (most Pythonic)
return text[::-1]
# Alternative methods:
# Method 2: Using reversed() and join()
# return ''.join(reversed(text))
# Method 3: Using a loop
# result = ""
# for char in text:
# result = char + result
# return resultAfter implementing reverse_string, you can test it:
# Run the specific test
python -m pytest tests/test_string_utils.py::TestStringUtils::test_reverse_string -v
# Or test it manually
from src.string_utils import reverse_string
print(reverse_string("hello")) # Should output: "olleh"Contributors will be recognized in several ways:
- README Contributors Section: Your name will be added to the contributors list
- Git History: Your commits will be part of the project history
- Learning Portfolio: Use this contribution in your programming portfolio
If you find a bug in existing code or tests:
- Create an issue describing the problem
- If you know how to fix it, submit a pull request
- Include test cases that demonstrate the bug
- Start with the simplest functions first
- Don't try to implement everything at once
- Read the function's docstring carefully
- Look at the test cases to understand expected behavior
- Use print statements to debug your code
- Consider edge cases in your implementations
- Optimize for readability first, then performance
- Add additional test cases if you think of edge cases
- Help review other students' contributions
- Not handling edge cases (empty strings, negative numbers, etc.)
- Not following the exact function signature (parameter names and types)
- Implementing functionality that doesn't match the docstring
- Not testing your code before submitting
- Python Basics: Python.org Tutorial
- Style Guide: PEP 8
- Type Hints: Python Type Hints
- Testing: pytest Documentation
- Algorithms: Algorithm Visualizations
If you're stuck:
- Read the function's docstring again
- Look at the test cases for examples
- Check the hints in the TODO comments
- Ask for help in project discussions
- Look up similar functions online for inspiration
- Pick a simple function like
reverse_string() - Read its docstring and understand what it should do
- Look at the test cases in
tests/test_string_utils.py - Implement the function
- Run the tests to make sure it works
- Celebrate your contribution! 🎊
Remember: Every expert was once a beginner. Don't be afraid to start small and learn as you go!
Happy coding! 🚀