8 kyu
Fundamentals: Return
10,693 of 23,537JasonFTW
Loading description...
Fundamentals
View
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Spoiler
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}
-
-
Your rendered github-flavored markdown will appear here.
-
Label this discussion...
-
No Label
Keep the comment unlabeled if none of the below applies.
-
Issue
Use the issue label when reporting problems with the kata.
Be sure to explain the problem clearly and include the steps to reproduce. -
Suggestion
Use the suggestion label if you have feedback on how this kata can be improved.
-
Question
Use the question label if you have questions and/or need help solving the kata.
Don't forget to mention the language you're using, and mark as having spoiler if you include your solution.
-
No Label
- Cancel
Commenting is not allowed on this discussion
You cannot view this solution
There is no solution to show
Please sign in or sign up to leave a comment.
but the test only expects the latter in C# && JS
A simple little exercise to gain familiarity with common math terms.
easy two points. Thanks !
Don't over think it, just use the relevant operators.
Can someone please explain what "modulus" has to do ?
Google can do a better job at it than us. In other words, it's remainder (after division).
Yhe, thanks my bro I find object in the Google.
OP solved it, closing
Can someone please explain what "modulus" has to do with the division with remainder?
what is exponent mean
Exponentiation operator If x and y are integer, float or double, x^y evaluates to x raised to the power y. Unlike other operators, exponentiation is right associative, so 2^3^2 = 2^(3^2) = 512, not (2^3)^2 = 64.
I believe the test cases should be a range of 0 - 100 instead of 1 - 100, as this would make the user also practice edge cases (division/mod by 0 should raise an exception) and a real prod environment should be ready to handle a common edge case like that.
This comment has been hidden.
Ruby Translation
Approved
python new test framework is required. updated in this fork
Approved
What was the point of this kata?
It's in the title.
It's not a 3 kyu task, and it's not intended to be.
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
FYI: https://en.wikipedia.org/wiki/Modulo_operation
I understand what you want to tell me
Testing for mod(77, 28): expected 49 to equal 21; Hmmm |77-28| = 49; what is the 21??.
And Testing for mod(37, 92): expected 55 to equal 37; |37-92| = 55, but not 37....
Modulo and difference are not the same thing.
This comment has been hidden.
Hi, when i test and attempt my code I pass all the tests but I cant submit my code. I refresh the page and i still cant submit my code. This is a recurring issue in many different katas and can it please be fixed.
Hi. Sorry but this is not kata issue (I mean, nobody can do anything with it here, this has no relation with the kata). A better place to ask for assistance would be to ask for help in Codewars Discord channel (see link on left panel). There you'll find active and competent users that may try to understand the issue and fix it if possible.
No requirements for dividing by zero.
The function does not expect behaviour any different from the underlying operator.
What requirement did you have in mind?
Just simple tests for cases n/0 and 0/0 - maybe not demanding throwing an error, but at least returning simple string like 'dividing by zero is not allowed'.
Code wars are very good for problem solving . But when I did an excersise the solution is using return statement instead of print ,I don't konw why?
Not a kata issue, that's hw CW works. Read this for more info
The description says to "print the sum, difference, ..." when values are expected to be returned instead.
Fixed (description changed)
Surely there is a better way to teach how to do functions and the return operator in python.
Beginners should be taught to be Pythonic from the beginning. No use reinventing the wheel. Other examples can be used to practice function definitions.
That's not an issue.
It would make more sense for the modulus dunction to take only one variable, not 2. Also, it would be helpful if the function of some functions, such as the exponential function, were made clearer.
You are confusing
mod
(the%
operator) withabs
.And yes, this kata needs more tests.
All the names of the functions could be 3-4 letters short - tiny bit less pointless typing
Not an issue (maybe suggestion).
Maybe you should mention that the division you are looking for is integer division. If you used a test case like divide(5, 2) the answer is 2.5 but it would return 2.
You could add a test case similar to divide(5, 2) to 'Your Test Cases' and it would become a little more obvious.
Zen of Python: "Explicit is better than implicit."
Actually the tests are set up so both are allowed.
I've put the information in the descriptions.
Please tell me which function fails in the test fixture. Otherwise I have to add a print statement to every function.
I'll be working on that, thanks. Haven't had the chance to work on this yet.
I don't think you need the uncommented note at the top of the code, though of course you can keep it if you like.
Alright, I'll remove it.
Thanks for the suggestion.