Answer to Question #267189 in Python for abuzer

Question #267189

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


1
Expert's answer
2021-11-16T13:52:57-0500
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)


    

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS