Skip to content
This repository has been archived by the owner on Aug 31, 2021. It is now read-only.

[Python] Implement new Concept Exercise: tuples #1097

Closed
BethanyG opened this issue Apr 3, 2020 · 0 comments · Fixed by #1824
Closed

[Python] Implement new Concept Exercise: tuples #1097

BethanyG opened this issue Apr 3, 2020 · 0 comments · Fixed by #1824
Assignees
Labels

Comments

@BethanyG
Copy link
Member

BethanyG commented Apr 3, 2020

This issue describes how to implement the tuples concept exercise for the Python track.

Getting started

Please please please read the docs before starting. Posting PRs without reading these docs will be a lot more frustrating for you during the review cycle, and exhaust Exercism's maintainers' time. So, before diving into the implementation, please read up on the following documents:

Please also watch the following video:

Goal

The goal of this exercise is to teach the basics of the Tuple (sequence type, immutable Sequence type) data type in Python.

Learning objectives

  • Create a tuple via constructor (tuple(_iterable_)), literal (a,b,c or (a, b, c)), & single literal (a, or (a,))
  • Understand that it is the comma in a sequence that makes a Tuple, and that the () are optional, except for denoting an empty Tuple or when omitting them creates ambiguity.
  • Understand that Tuples are an immutable data type (like Strings). Changing a Tuple means creating a new copy.
  • Understand that Tuples can contain other Tuples. (e.g. Tuples can be nested).
  • Create a new Tuple from two or more previous Tuples via concatenation using the + operator.
    * Create a new Tuple by multiplying a previous Tuple using the * operator.
  • Access values in a tuple via index & using [] (bracket notation).
  • Check for membership of an item in a given tuple.
  • Iterate through a tuple using for item in.

Out of scope

  • Sequence type methods such as min(), max(), x.index(), x.count(), len(), or hash()
  • Additional builtin functions as they relate to this data structure (e.g. sorted(), enumerate(), or reversed().
  • Slicing or slice notation ([start:stop:step])
  • Knowing that Tuples can be used as objects in other data structures, -- e.g. " a "List of Tuples", "Tuples as keys in Dictionaries", ,or "A Set of Tuples".
  • Create a new Tuple by multiplying a previous Tuple using the * operator.
  • Hash-ability and when a Tuple is not hash-able.
  • Related collections module with namedtuple()
  • Memory and performance characteristics.

Concepts

  • tuples
  • immutability
  • indexing
  • concatenation
  • iteration

Prerequisites

Resources to refer to

Hints

Hints should link to the Tuples section of the Python docs tutorial: Tuples.

After

After, the student can explore slicing syntax, although it will be taught in separate exercises. This might also be a good time to explore the concept of hash-ability & the use of Tuples as keys in a dictionary. Additionally, the student can take a look at additional sequence type methods, or how built-in methods such as sorted(), enumerate(), min(), or max() can be used with Tuples.

Representer

No changes required.

Analyzer

No changes required.

Implementing

Tests should be written using unittest.TestCase, and the test file named dicts_basic_test.py.
Please see Implementing a Concept Exercise for additional instructions and details.

Help

If you have any questions while implementing the exercise, please post the questions as comments in this issue.

Edits

  • edited for updated naming by @yawpitch
  • edited problem description to include nested tuples but exclude len() as out of scope.
  • removed * multiplication from learning objectives.
@BethanyG BethanyG added status/help-wanted Extra attention is needed type/new-exercise Add a new exercise track/python labels Apr 3, 2020
@yawpitch yawpitch changed the title [Python] Implement new Concept Exercise: tuples-basic [Python] Implement new Concept Exercise: tuples Apr 23, 2020
@BethanyG BethanyG self-assigned this May 15, 2020
@BethanyG BethanyG linked a pull request Jul 4, 2020 that will close this issue
@BethanyG BethanyG removed the status/help-wanted Extra attention is needed label Jul 4, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant