Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

how to find largest number in array in python

#Initialize array     
arr = [25, 11, 7, 75, 56];     
     
#Initialize max with first element of array.    
max = arr[0];    
     
#Loop through the array    
for i in range(0, len(arr)):    
    #Compare elements of array with max    
   if(arr[i] > max):    
       max = arr[i];    
           
print("Largest element present in given array: " + str(max));   
Comment

find highest value in array python

// you can just use the max function on an array to find the max
arr = [1, 7, 3, 9]
max(arr) // returns 9 because it is the largest
Comment

PREVIOUS NEXT
Code Example
Python :: free download django app for windows 10 
Python :: python for enumerate 
Python :: how to comment text in python 
Python :: django filter multiple conditions 
Python :: python get file line count 
Python :: python dash log scale button 
Python :: uninstall every package in environment 
Python :: NLP text summarization with Luhn 
Python :: transform image to rgb python 
Python :: python removing duplicate item 
Python :: read list stored as a string with pandas read csv 
Python :: python dataframe calculate difference between columns 
Python :: number of elements in the array numpy 
Python :: pandas knn imputer 
Python :: convert string to int dataframe column 
Python :: python while loop break 
Python :: python sys 
Python :: largest number python 
Python :: django model query join 
Python :: pyqt setfocus 
Python :: structure ternaire python 
Python :: how to append to a list in python 
Python :: lucky number codechef solution 
Python :: python evaluate string 
Python :: x y coordinates in python 
Python :: django changing boolean field from view 
Python :: convert int to string python 
Python :: print format python 
Python :: django email 
Python :: add image to pdf with python 
ADD CONTENT
Topic
Content
Source link
Name
1+1 =