Max in list Python
Ngày đăng:
14/02/2022
Trả lời:
0
Lượt xem:
84
Python program to find largest number in a listGiven a list of numbers, the task is to write a Python program to find the largest number in given list. Examples: Input : list1 = [10, 20, 4] Output : 20 Input : list2 = [20, 10, 20, 4, 100] Output : 100Method 1 : Sort the list in ascending order and print the last element in the list.
Output: Largest element is: 99Method 2 : Using max() method
Output: Method 3 : Find max list element on inputs provided by user
Output: Enter number of elements in list: 4 Enter elements: 12 Enter elements: 19 Enter elements: 1 Enter elements: 99 Largest element is: 99Method 4 : Without using built in functions in python:
Output: Largest element is: 99Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics. To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning - Basic Level Course
Article Tags :
Python Python Programs
Python list-programs python-list Practice Tags :
python-list
Read Full Article
|