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 :: python check disk space 
Python :: how to run function on different thread python 
Python :: rename files in folder python 
Python :: os file exists 
Python :: tf.contrib.layers.xavier_initializer() tf2 
Python :: python save .mat 
Python :: python every other including first 
Python :: from sklearn.metrics import classification_report 
Python :: python r before string 
Python :: python armstrong number 
Python :: python wsgi server 
Python :: torch save 
Python :: select text in a div selenium python 
Python :: data science standard deviation 
Python :: pyqt tex 
Python :: python time function duration and memory usage 
Python :: remove whitespace in keys from dictionary 
Python :: how to change the title of a tkinter widnow 
Python :: how to get the live website html in python 
Python :: python copy all files in a folder to nother folder 
Python :: fill na with mode and mean python 
Python :: python if not path exist make path 
Python :: plotly hide trace 
Python :: change column value based on another column pandas 
Python :: pandas dataframe print decimal places 
Python :: Install Basemap on Python 
Python :: how to find the version of python command linw 
Python :: how to open csv file in python 
Python :: python lowercase 
Python :: python emoji 
ADD CONTENT
Topic
Content
Source link
Name
1+1 =