The manager of the company has informed his assistant to enter the age
of all the workers working in production department. Among all he has to
find the employee with maximum age employee. Help the manager to
find the maximum age employee by storing the all age of all employee in
1D array dynamically. Use functions to solve the task.
Input Format
19 21 22 23 18
Constraints
All numbers should be greater than 0.If constraints are not matched then
display "wrong input"
Output Format
23
n=int(input("Enter number of employees: "))
ages=[]
#get inputs from the user
for i in range(n):
print("Enter age of employee ",(i+1))
age=int(input())
if age<=0:
print("Wrong input")
break;
ages.append(age)
#find maximum age
max_age=ages[0]
for i in ages:
if i>max_age:
max_age=i
print("Maximum age = ",max_age)
Comments
Leave a comment