Challenge: Namedtuples, Stacks and Queues
Test your understanding of namedtuples, stacks and queues with these coding questions.
Problem 1
Task: Create a namedtuple called Task with fields id
and name
.
- Make a stack of 3 tasks.
- Pop one task from the stack.
- Print the popped task.
Python 3.10.4
from collections import namedtuple, deque# Write your code here
Problem 2
You are given a set of tasks. Each task has three fields:
id
(an integer ID)name
(a string description)time
(time in minutes)
You should:
- Store all tasks in a queue