Search⌘ K
AI Features

Challenge: Namedtuples, Stacks and Queues

Explore how to implement namedtuples alongside stacks and queues to manage and process tasks efficiently. Understand how to organize tasks by time and priority, and practice scheduling strategies that handle quick and urgent tasks first.

We'll cover the following...

Problem 1

Task: Create a namedtuple called Task with fields id and name.

  1. Make a stack of 3 tasks.
  2. Pop one task from the stack.
  3. 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:

...