Create a function that takes a number as an argument and returns negative of that number. Return negative numbers without any change.
Examples:
negative(4) ➞ -4 negative(15) ➞ -15 negative(-4) ➞ -4 negative(0) ➞ 0
Hints:
You can make use of
You can add an
You can make use of
< operator with an if statement to check if n is negative.
You can add an
else statement to handle the case when n is positive.
Free plan: 30 tutor messages. Premium is unlimited.
Saved
Ctrl + Enter to check