Tuples – Operations, online
Six activities your students do on their own devices. See who's finished, and their scores.
Learning
Understanding
Testing
Tuples – Operations in one minute
What students need to know
Enum is imported from Python's built-in enum module. .value returns the integer (or string) assigned to the member.
An enum gives meaningful names to a fixed set of values — like Color.RED instead of 1. Color.REED would be an error; 'reed' would silently pass through.
Mistakes students make
- Must import Enum first: from enum import Enum.
- Duplicate values create aliases, not new members. Use unique values.
- Cannot reassign enum members they are immutable.
- Convention: enum member names should be UPPER_CASE.
PREVIOUS · MODULE 59Tuples – Basics
YOU ARE HERE · MODULE 60Tuples – Operations
NEXT · MODULE 61Tuples – Practical Use
What students will learn in this module
Every question in Module 60
Quick questions
- What is an enumeration?AA set of named constantsBA type of list
- Why use enums instead of strings?APrevents typos and invalid valuesBThey're faster
- Color.RED.value returns?AThe value assigned to RED (e.g., 1)BThe string 'RED'
- Color.RED.name returns?A1B'RED' (the name as a string)
- Can enum members be compared?ANoBYes Color.RED == Color.RED is True
Key terms
Students type the meaning of:
EnumMember.value.name
Match the pairs
from Enum import enumMatch it to what it doesColor(RED)Match it to what it doesfrom enum import EnumMatch it to what it doesColor.RED.valueMatch it to what it doeslist(range(3))Match it to what it doestype(True)Match it to what it doesFill in the blanks
from enum import ____ class Color(Enum): RED = 1class Color(____): RED = 1print(Color.RED._____)
print(Color.RED.____)
for c in _____: print(c)
Spot the error
Question 1
Aclass Color(Enum):B RED = 1
Question 2
Afrom enum import EnumBCclass Color(Enum):D RED = 1E GREEN = 1
Question 3
Afrom enum import EnumBCclass Color(Enum):D RED = 1EFColor.RED = 2
Question 4
Afrom enum import EnumBCclass Color(Enum):D red = 1
Question 5
Afrom enum import EnumBCclass Color(Enum):D RED = 1EFif color == 'RED':
