Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added multiply function and unit tests #40

Merged
merged 3 commits into from
Jan 12, 2025
Merged

Added multiply function and unit tests #40

merged 3 commits into from
Jan 12, 2025

Conversation

NimahMasuud
Copy link

  • Implemented the multiply function to handle multiplication of two numbers with type validation.
  • Added comprehensive unit tests for multiply function covering:
    • Positive and negative numbers
    • Zero multiplication
    • Floating-point numbers
    • Invalid inputs with error handling
  • Applied Ruff linting to ensure code quality and PEP8 compliance.

@NimahMasuud NimahMasuud added the code challenge challenge for CDS program label Jan 11, 2025
@NimahMasuud NimahMasuud self-assigned this Jan 11, 2025
@AhmadHamedDehzad AhmadHamedDehzad self-requested a review January 11, 2025 14:07
Copy link

@AhmadHamedDehzad AhmadHamedDehzad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My review and Observations
Code Quality
The multiply function is really easy to read and understand.
It has a docstring that explains what the function does, what the inputs are, what it returns, and even examples of how to use it. That’s really helpful for beginners like me!
The function checks if the inputs are numbers, which makes it safer to use because it raises an error if something invalid is passed.
Code Formatting
The code looks clean and follows Python's style rules (PEP 8). The indentation and spacing are good.
There is a line at the top, #!/usr/bin/env python3, which I learned makes the script run in different environments easily. That’s a nice touch!
Testing Coverage
The tests are really good because they check for a lot of different cases:
Positive and negative numbers
Multiplying with zero
Invalid inputs like strings or None
The unittest framework is used, which is great because it’s built into Python and doesn’t need extra setup.
I like how the tests use assertEqual to check if the function is doing the right thing.
What I Learned
Writing docstrings is really important for explaining the code, and examples in the docstring make it even better.
Using type hints like float and type checks like isinstance makes the function easier to understand and prevents errors.
Testing different kinds of inputs (positive, negative, zero, invalid) helps make the function more reliable.
Overall
The code is clean, well documented, and the tests are thorough. As a beginner, I found it easy to understand and learned some good coding practices from it. 😊

@NimahMasuud NimahMasuud merged commit b53f573 into main Jan 12, 2025
8 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code challenge challenge for CDS program
Projects
Development

Successfully merging this pull request may close these issues.

2 participants