How to Find the Second Largest Number in a List | EP-20 Find the Second Largest Number in a List

Subscribers:
27,900
Published on ● Video Link: https://www.youtube.com/watch?v=PdJn6SVk1EU



Duration: 11:27
121 views
5


Method 1 : Using sort()- ascending

"""Algorithm
1. initialized list with values.
2.Print the initialized list
3.The sort() function is used to sort the list in descending order,or ascending order.
4.The sorted list is printed using the print() function.
5.The second largest number is printed using the print() function and the index of
the second largest number in the sorted list (which is 1, since list indexes start from(descending) 0 or
which is -2, since the list indesxes start from -1 ()ascending).
"""
list1 = [0,1,8,9,10,9,11,5]
print(list1)
list1.sort(reverse=False)
print(list1)
print(list1[-2])

method 2: descending
list1.sort(reverse=True)
print(list1)
print(list1[1],"descending")


method 3:using sorted method
print("finding the second lagerest element using sorted method: ",sorted(list1)[-2])


method 4: by removing max element from list
new_list =set(list1)
print(new_list)
new_list.remove(max(new_list))
print(new_list)
print(max(new_list))

#python #coding #tutorial #programming #algorithms #datascience #problem solving #secondlargestnumber #pythonprogramming #codingtutorial #pythontips #codingtricks #pythonchallenge #codingchallenge #learntocode #code #developer #programmer #softwaredeveloper #codinglife #codingcommunity #pythoncommunity #tech #technology #youtubetutorial #howto #tutorialvideo #PythonTutorial #LearnPython #DataStructures #TechTutorial #CodeWithMe #pythoninterviewquestions

Connect With Us:
—————————————
➡️ Website: https://www.cybrosys.com/
➡️ Email: info@cybrosys.com
➡️ Twitter:   / cybrosys  
➡️ LinkedIn:   / cybrosys  
➡️ Facebook:   / cybrosystechnologies  
➡️ Instagram:   / cybrosystech  
➡️ Pinterest:   / cybrosys  




Other Videos By Cybrosys Technologies


2024-08-01Passkey Authentication in Odoo 18 | Auth Passkey in Odoo 18 | How to Configure Passkey in Odoo 18
2024-07-31How to Manage Open Jobs as well as Application Form in Recruitment Software for Free | Horilla HRMS
2024-07-31How to Configure Product Category in Odoo 17 |Product Category Management in Odoo 17 |Odoo 17 Videos
2024-07-31How to Manage User Sessions, Devices In Odoo 18 |Session Management in Odoo 18 |Odoo 18 New Features
2024-07-30Under Warranty in Odoo 18 Field Service | Odoo 18 Field Service Management | Odoo 18 New Features
2024-07-30What is List Comprehension in Python? | EP-21 List Comprehension in Python | Free Python Tutorials
2024-07-30How to Set Up Recruitment Survey Form in Recruitment Software for Free | Horilla HRMS Software
2024-07-29How to Configure Storno Accounting in Odoo 17 | Storno Accounting in Odoo 17 | Odoo 17 Accounting
2024-07-29How to Create a Candidate in Recruitment Software for Free | Best Recruitment Software |Horilla HRMS
2024-07-29Odoo 18 New Features | Expected Features in Odoo 18 | Odoo 18 Upcoming Features | EP-2 Tech Tonic
2024-07-28How to Find the Second Largest Number in a List | EP-20 Find the Second Largest Number in a List
2024-07-25Signature Request in Odoo 18 | How to Request an Online Sign to Confirm Orders| Odoo 18 New Features
2024-07-25Pricer Store in Odoo 18 POS | How to Configure Pricer Store in Odoo 18 POS | New features in Odoo 18
2024-07-24What is List Slicing in Python | EP-19 List Slicing in Python | How to Slice Lists in Python
2024-07-24Odoo 18 New Report Layouts & Fonts | How to Create New Report Layouts | New features in Odoo 18
2024-07-23Cloud Storage Application in Odoo 18 | Cloud Storage App in Odoo 18 | Latest Features in Odoo 18
2024-07-23Confirm & Reset Button for Selecting Multiple Companies in Odoo 18 | New Features in Odoo 18
2024-07-22What are List Operations in Python | EP-18 List Operations in Python | List Methods In Python
2024-07-22How to Scan CV Using AI in Odoo 18 | Artificial Intelligence to Scan CV | New Features in Odoo 18
2024-07-22How to Create Approval Type in Odoo 17 Approval | What are the Different Approval Types in Odoo 17
2024-07-21How to Count Records Using Search Count in Odoo 17 | Odoo 17 Development Tutorials | Search_Count()



Tags:
Find Second Largest Number Python
Python Code For Second Largest Number
Python Program To Find Second Largest Number
Python Tutorial Second Largest Number
Efficient Way To Find Second Largest Number Python
Second Largest Number Python Code
Python Largest Number
Python List
Python Programming
Python Tutorial
Python Tips
Python Challenge
Coding Community
Python Community
Python
Python Interview Questions
Learn Python
Python for beginners
Data structures
Coding