How do I find the maximum of 2 numbers?

后端 未结 10 1956
借酒劲吻你
借酒劲吻你 2020-12-03 02:22

How to find the maximum of 2 numbers?

value = -9999
run = problem.getscore()

I need to compare the 2 values i.e value and

相关标签:
10条回答
  • 2020-12-03 02:42

    Use the builtin function max.

    Example: max(2, 4) returns 4.

    Just for giggles, there's a min as well...should you need it. :P

    0 讨论(0)
  • 2020-12-03 02:43
    numberList=[16,19,42,43,74,66]
    
    largest = numberList[0]
    
    for num2 in numberList:
    
        if num2 > largest:
    
            largest=num2
    
    print(largest)
    

    gives largest number out of the numberslist without using a Max statement

    0 讨论(0)
  • 2020-12-03 02:50

    max(number_one, number_two)

    0 讨论(0)
  • 2020-12-03 02:52

    max()

    0 讨论(0)
  • 2020-12-03 02:53

    (num1>=num2)*num1+(num2>num1)*num2 will return the maximum of two values.

    0 讨论(0)
  • 2020-12-03 02:59
    max(value,run)
    

    should do it.

    0 讨论(0)
提交回复
热议问题