# Python: Find the three largest integers from a given list of numbers using Heap queue algorithm

## Python heap queue algorithm: Exercise-1 with Solution

Write a Python program to find the three largest integers from a given list of numbers using the heap queue algorithm.

**Sample Solution**:

**Python Code:**

```
import heapq as hq
nums_list = [25, 35, 22, 85, 14, 65, 75, 22, 58]
print("Original list:")
print(nums_list)
# Find three largest values
largest_nums = hq.nlargest(3, nums_list)
print("\nThree largest numbers are:", largest_nums)
```

Sample Output:

Original list: [25, 35, 22, 85, 14, 65, 75, 22, 58] Three largest numbers are: [85, 75, 65]

**Flowchart:**

**Python Code Editor:**

**Have another way to solve this solution? Contribute your code (and comments) through Disqus.**

**Previous:** Python heap queue algorithm Exercise Home.

** Next:** Write a Python program to find the three smallest integers from a given list of numbers using Heap queue algorithm.

**What is the difficulty level of this exercise?**

Test your Programming skills with w3resource's quiz.

**Weekly Trends**- Python Interview Questions and Answers: Comprehensive Guide
- Scala Exercises, Practice, Solution
- Kotlin Exercises practice with solution
- MongoDB Exercises, Practice, Solution
- SQL Exercises, Practice, Solution - JOINS
- Java Basic Programming Exercises
- SQL Subqueries
- Adventureworks Database Exercises
- C# Sharp Basic Exercises
- SQL COUNT() with distinct
- JavaScript String Exercises
- JavaScript HTML Form Validation
- Java Collection Exercises
- SQL COUNT() function
- SQL Inner Join