Open Bug 1756948 Opened 3 years ago Updated 7 months ago

There is a built-in function max() not worked as it should

Categories

(L20n :: Python Library, defect, P1)

Tracking

(Not tracked)

UNCONFIRMED

People

(Reporter: vermajanvi57, Unassigned)

Details

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.102 Safari/537.36

Steps to reproduce:

I used the python funtion max() to find the maximum number from 2 numbers.
It gives me expected output when i used only positive numbers. But it not worked for Negative numbers..

i have suggestion to resolve it
we can modify this as written below:
num1 = -4
num2 = -2
if(num1&&num2 <0):
if(num1>num2):
return num2
else:
num1

else:
if num1>=num2:
return num1
else:
num2

m=max(num1,num2)
print(m)

Ans is -4

Actual results:

num1 = -4
num2 = -2
m=max(num1,num2)
print(m)

Ans is -4

num1 = 10
num2 = 20
m=max(num1,num2)
print(m)

Ans is 20

Expected results:

num1 = -4
num2 = -2
m=max(num1,num2)
print(m)

Ans should -2

num1 = 10
num2 = 20
m=max(num1,num2)
print(m)

Ans is 20

Flags: needinfo?(vermajanvi57)
OS: Unspecified → All
Priority: -- → P1
Hardware: Unspecified → All
Summary: There is a built-in function max() nit worked as it should → There is a built-in function max() not worked as it should
Flags: needinfo?(vermajanvi57)
You need to log in before you can comment on or make changes to this bug.