When you're evaluating -12**2 you're essentially evaluating -(12**2).
And also, (-12) squared is always 144.
If you want to retain the sign use -(12**2). If you don't want the sign to be retained, use (-12)**2
If you're trying to evaluate the square root of a negative number. It is going to be the same as the sqrt of the positive number multiplied by imaginary i
Just evaluate negative numbers the same way you would positive numbers, and append i to it.
In your particular case, the min function is screwing things up when you evalute negative numbers
Should I use answer = 0 - var or is answer = -var enough?
For those of you familiar with finance: I have the term S from black-scholes model set to the variable s, and depending on whether i say to value a call or a put, I will use s or -s
Python negative values in variables in multiplication - Stack Overflow
working with negative numbers in python - Stack Overflow
If I want to use negative of a variable, is -var enough?
Is there any language in which negative numbers are false?
Perhaps you would accomplish this with something to the effect of
text = raw_input("please give 2 numbers to multiply separated with a comma:")
split_text = text.split(',')
a = int(split_text[0])
b = int(split_text[1])
# The last three lines could be written: a, b = map(int, text.split(','))
# but you may find the code I used a bit easier to understand for now.
if b > 0:
num_times = b
else:
num_times = -b
total = 0
# While loops with counters basically should not be used, so I replaced the loop
# with a for loop. Using a while loop at all is rare.
for i in xrange(num_times):
total += a
# We do this a times, giving us total == a * abs(b)
if b < 0:
# If b is negative, adjust the total to reflect this.
total = -total
print total
or maybe
a * b
Too hard? Your TA is... well, the phrase would probably get me banned. Anyways, check to see if numb is negative. If it is then multiply numa by -1 and do numb = abs(numb). Then do the loop.