w3resource

Python: Data Structures - Exercises, Practice, Solution

Data Structures: [7 exercises with solution]

[An editor is available at the bottom of the page to write and execute the scripts.]

1. Write a Python program to locate the left insertion point for a specified value in sorted order. Go to the editor
Expected Output:
4
2
Click me to see the sample solution

2. Write a Python program to locate the right insertion point for a specified value in sorted order. Go to the editor
Expected Output:
3
2
Click me to see the sample solution

3. Write a Python program to insert items into a list in sorted order. Go to the editor
Expected Output:
Original List:
[25, 45, 36, 47, 69, 48, 68, 78, 14, 36]
Sorted List:
[14, 25, 36, 36, 45, 47, 48, 68, 69, 78]
Click me to see the sample solution

4. Write a Python program to create a queue and display all the members and size of the queue. Go to the editor
Expected Output:
Members of the queue:
0 1 2 3
Size of the queue:
4
Click me to see the sample solution

5. Write a Python program to find whether a queue is empty or not. Go to the editor
Expected Output:
True
False
Click me to see the sample solution

6. Write a Python program to create a FIFO queue. Go to the editor
Expected Output:
0 1 2 3
Click me to see the sample solution

7. Write a Python program to create a LIFO queue. Go to the editor
Expected Output:
3 2 1 0
Click me to see the sample solution

 

Python Code Editor:

More to Come !

Do not submit any solution of the above exercises at here, if you want to contribute go to the appropriate exercise page.

Test your Python skills with w3resource's quiz



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://www.w3resource.com/python-exercises/data-structures-and-algorithms/python-data-structure.php