Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Aprenda Challenge: Unpacking Tuple Elements | Packing and Unpacking in Python
Functional Programming Concepts in Python
Seção 1. Capítulo 7
single

single

Challenge: Unpacking Tuple Elements

Deslize para mostrar o menu

Tarefa

Deslize para começar a programar

Given a tuple of numbers, write a function that unpacks the first and last elements and returns their sum.

  • Unpack the first and last elements from the numbers tuple.
  • Calculate and return the sum of the extracted first and last elements. If the tuple contains only one item, return that item added to itself.
  • Use the extended iterable unpacking syntax (first, *middle, last) = numbers to isolate the first and last elements from the tuple when it contains more than one item.
  • Replace the brackets (___) in the code with your implementation.

Solução

Switch to desktopMude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo
Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 1. Capítulo 7
single

single

Pergunte à IA

expand

Pergunte à IA

ChatGPT

Pergunte o que quiser ou experimente uma das perguntas sugeridas para iniciar nosso bate-papo

some-alt