Saturday, 28 July 2018

Find Largest Element of an Array using Function in Python

# Find Largest Element of an Array using Function

# python function to find maximum
# in arr[] of size n
def largest(arr,n):

# Initialize maximum element
max = arr[0]

# Traverse array elements from second
# and compare every element with
# current max
for i in range(1, n):
if arr[i] > max:
max = arr[i]
return max
# Drive Code
arr =[i for i in  range(100)]
n = input(" Enter total number of elements(1 to 100):")

for i in range(n):
    arr[i]=  input(" Enter Number for index {0} ".format(int(i)));

Ans = largest(arr,n)
print ("Largest in given array is",Ans)


1 comment:

  1. Sir What is the scope of Python
    Should i learn it or not at this time


Excel read, Two days different in Python

Program: import pandas as pd df = pd.read_excel('CompleteData2.xlsx', sheet_name='Test') df.DOA = pd.to_datetime(df[...