[wptelegram-join-channel]

### Python Program to accept numbers and Find the maximum and minimum element of the numbers entered by the user

### Problem Definition:

Write a Python Program to accept numbers from the user until the user enters done. Find the maximum and minimum elements of the numbers entered by the user. Use class and methods concepts.

#### Program source code in Python to accept numbers and Find the maximum and minimum element of the numbers entered by the user

### Video Tutorial

class Numbers: def __init__(self): self.values = [] def maximum(self): max = 0 for i in self.values: if i > max: max = i print ("The maximum element is ", max) def minimum(self): min = 999 for i in self.values: if i < min: min = i print ("The minimum element is ", min) def insert(self): num = int (input("Enter the element: ")) self.values.append(num) x = Numbers() while True: x.insert() str = input("Do you wish to enter more elements press y otherwise enter done: ") if str == 'Done': break; x.maximum() x.minimum()

#### Output of Program:

Enter the element: 10

Do you wish to enter more elements press y otherwise enter done: y

Enter the element: 20

Do you wish to enter more elements press y otherwise enter done: y

Enter the element: 15

Do you wish to enter more elements press y otherwise enter done: y

Enter the element: 48

Do you wish to enter more elements press y otherwise enter done: y

Enter the element: 5

Do you wish to enter more elements press y otherwise enter done: Done

The maximum element is 48

The minimum element is 5

#### Summary:

This article discusses, how to write a Python program to accept numbers and Find the maximum and the minimum number of the numbers entered by the user. Subscribe to our **YouTube channel** for more videos and like the **Facebook page** for regular updates.