Unpack a Tuple
Beginner · Write the code · from Python Tuples: When and Why to Use Immutable Sequences
From the lesson: Python Tuples: When and Why to Use Immutable Sequences
Think about GPS coordinates. A location like (40.7128, -74.0060) represents New York City. If you accidentally changed one of those numbers, the location would point somewhere completely different. Some data simply should not change after you create it.
Read the lessonA tuple representing a student record is given. Unpack it into three variables: name, age, and grade.
Then print each variable on its own line.
Expected output:
Emma
16
Astudent = ('Emma', 16, 'A')
# Unpack the tuple into name, age, grade
# Print each variable
More Tuples exercises
- Create a Tuple and Access ElementsBeginner
- Predict the Output: Single Item TupleBeginner
- Fix the Bug: Modifying a TupleBeginner
- Loop and Unpack Student ScoresIntermediate
All Python exercises · 50 practice problems · Data Structures quiz