M
M
Mikhail Smailovich2020-06-10 16:15:50
Mathematics
Mikhail Smailovich, 2020-06-10 16:15:50

The input is two numbers other than zero. How to display the second number with the sign of the first?

Only elementary arithmetic is available, no ifs and modules (upd.: ...and other built-in python functions).
It will be very cool not to lay out the solution, but to give a couple of hints so that you have the opportunity to think for yourself.
upd2: Thanks to dimonchik2013 for the brilliant solution
5ee1915dec897311877269.jpeg

Answer the question

In order to leave comments, you need to log in

4 answer(s)
G
galaxy, 2020-06-10
@smi33

More in the piggy bank of perversions:math.sqrt(a*a) / a * math.sqrt(b*b)

T
tema_sun, 2020-06-10
@tema_sun

Divide the first by abs(first) and multiply the second by that result.

M
Montik01, 2020-06-11
@Montik01

I don’t know how exactly it will be in Python, but purely mathematically it looks like this:

a * b / √( a * a )

Will I be taken to Google?)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question