From a book that programmers can learn (Python): Conditional search (maximum value)

Continuing from Last time, I am reading the search problem. Here, the value is searched from the relationship with other values to find the maximum value.

Conditional search (maximum value) Click here for C ++ answer code
const int ARRAY_SIZE = 10;
int intArray[ARRAY_SIZE] = {4,5,9,12,-4,0,-57,30987,-287,1};
int highestValue = intArray[0];
for (int i = 1; i < ARRAY_SIZE; i++) {
    if (intArray[i] > highestValue) highestValue = intArray[i];

Your answer Python3
#!/usr/bin/env python
#coding:utf-8

def MaxSearch():
    ARRAY_NUMBER = [4,5,9,12,-4,0,-57,30987,-287,1]
    maxValue = ARRAY_NUMBER[0]
    for x in range(len(ARRAY_NUMBER)):
        if ARRAY_NUMBER[x] > maxValue:
            maxValue = ARRAY_NUMBER[x]

    print(maxValue)

・ ・ ・ (Terminal execution)
>>> from test31 import MaxSearch
>>> MaxSearch()
30987
>>> 

Refer to the previous comment I intended to shorten it myself, but the maximum value was requested!

For reference from the previous comment Is there a Python method Python standard library I searched here, but I couldn't find anything that seems to be a method to find the maximum value. So is it better to look at the maximum values in order?

Recommended Posts

From a book that programmers can learn (Python): Conditional search (maximum value)
From a book that programmers can learn (Python): Statistical processing-deviation value
From a book that programmers can learn ... (Python): Pointer
From a book that programmers can learn ... (Python): About sorting
From a book that programmers can learn (Python): Decoding messages
From a book that programmers can learn (Python): Find the mode
From a book that programmers can learn ... (Python): Review of arrays
From a book that programmers can learn (Python): Class declaration (public / private, etc.)
From a book that programmers can learn ... Collect small problem parts
From a book that programmers can learn ... Verification of rune checksum (variable length) Part 2
From a book that programmers can learn: Converting characters that represent numbers to integer types
From a book that makes the programmer's way of thinking interesting (Python)
8 services that even beginners can learn Python (from beginners to advanced users)
[Python algorithm] A program that outputs Sudoku answers from a depth-first search
"Python Kit" that calls a Python script from Swift
A mechanism to call a Ruby method from Python that can be done in 200 lines
Programmer's way of thinking is from XX book (Python)
"A book that understands Flask from scratch" Reading memo
Programmer's way of thinking is from XX book (Python)
A Python script that goes from Google search to saving the Search results page at once
A memo that reads data from dashDB with Python & Spark
A Python program in "A book that gently teaches difficult programming"
python Condition extraction from a list that I often forget
A Python program that aggregates time usage from icalendar data
Extract the value closest to a value from a Python list element
[Python] A program that finds the maximum number of toys that can be purchased with your money
[Python] Make a graph that can be moved around with Plotly
I made a package that can compare morphological analyzers with Python
Make a Kindle book that images mathematical formulas from TeX files
Created a library for python that can easily handle morpheme division
I made a shuffle that can be reset (reverted) with Python
[python] I made a class that can write a file tree quickly