About 602,000 results
Open links in new tab
  1. python max negative values - Stack Overflow

    Mar 3, 2017 · While entering the negative numbers as below, I want to extract the max value. I expect that value to be -0.123, but the actual value (in Python 3.6.0 shell) is -45.02. Here is my code: x=input("E...

  2. python - Find max with negative numbers - Stack Overflow

    May 5, 2017 · Consider the following approach using built-in max () function: print('Enter a number (0 to finish): ', end = '') num = int(input()) if num > 0: positives.append(num) elif num < 0: negatives.append(num) else: finished = True.

  3. python - Highest Negative Value - Stack Overflow

    Jun 27, 2017 · Just use inbuilt max function to find maximum number. numbers = [] done = False while not done: number = int(input("Enter another number (0 to end): ")) if number < 0: numbers.append(number) else: done = True print(max(numbers))

  4. Working with Negative Numbers in Python - GeeksforGeeks

    Mar 1, 2024 · Working with Negative Numbers in Python. Below are some examples by which can understand the working of Negative Numbers in Python: Arithmetic Operation; Absolute Value; Conditional Statements; Built-in Functions ; Using Math Module; Arithmetic Operation with Negative Numbers in Python

  5. Python - max() function - GeeksforGeeks

    Nov 30, 2023 · We can use max () function to locate the largest item in Python. Below are some examples: The code initializes three variables with values (var1 = 4, var2 = 8, var3 = 2) and then finds the maximum value among them using the max() function. The result, that is …

  6. max function but with negative values : r/learnpython - Reddit

    Oct 9, 2020 · print(“Largest: “ +str(max(values))) it works, but when i try to input negative numbers, it prints just the biggest number, not what the actual biggest value is. an example is when i input -1,-2,-3 it will output -3. can anyone help?

  7. Python's max() function for negative integers - aoverflow.com

    The max()Python function returns the number with the largest absolute value from a list: arr='-1 -2 -2 -3' arr=arr.split() m=max(arr) print(m) This code returns -3. The only thing I've come up with to return the largest number is to convert integers to floats, …

  8. The max function - maximum number in python | Trepachev …

    The max function returns the maximum number from a group of numbers specified in the parameters. You can specify a group of numbers by listing them separated by commas, or a sequence: list, tuple, set.

  9. Using the Max Function in Python - Pierian Training

    Apr 28, 2023 · It’s also possible to use the max () function with negative numbers: In this case, the max () function returns the largest negative number among its arguments. The max () function can also be used with variables that store numeric values:

  10. Python max() Function - W3Schools

    The max() function returns the item with the highest value, or the item with the highest value in an iterable. If the values are strings, an alphabetically comparison is done.

  11. Some results have been removed
Refresh