Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Single Return Value | Function Return Value Specification
Python Functions Tutorial
course content

Conteúdo do Curso

Python Functions Tutorial

Python Functions Tutorial

1. What is a Function in Python?
2. Positional and Optional Arguments
3. Arbitrary Arguments
4. Function Return Value Specification
5. Recursion and Lambda Functions

bookSingle Return Value

A single return value of a function in Python refers to returning a single object or value from a function. This type of return value has been used in previous sections.

12345
def add_numbers(a, b): return a + b result = add_numbers(3, 5) print(result) # outputs: 8
copy

The function add_numbers takes two arguments, adds them, and returns a single value — their sum. In this example, the result is stored in the variable result and printed to the console.

Note

The join() function in Python is used to join the elements of an iterable, such as a list, into a single string. Learn more about the join function here.

Tarefa
test

Swipe to show code editor

Your task is to complete the function so that it merges strings from different lists and returns the resulting string as output:

  1. You have to use arbitrary arguments because we don't know the number of lists to merge.
  2. Iterate all lists to merge the strings inside the function body.
  3. Return the resulting string using return keyword.

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 4. Capítulo 1
toggle bottom row

bookSingle Return Value

A single return value of a function in Python refers to returning a single object or value from a function. This type of return value has been used in previous sections.

12345
def add_numbers(a, b): return a + b result = add_numbers(3, 5) print(result) # outputs: 8
copy

The function add_numbers takes two arguments, adds them, and returns a single value — their sum. In this example, the result is stored in the variable result and printed to the console.

Note

The join() function in Python is used to join the elements of an iterable, such as a list, into a single string. Learn more about the join function here.

Tarefa
test

Swipe to show code editor

Your task is to complete the function so that it merges strings from different lists and returns the resulting string as output:

  1. You have to use arbitrary arguments because we don't know the number of lists to merge.
  2. Iterate all lists to merge the strings inside the function body.
  3. Return the resulting string using return keyword.

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 4. Capítulo 1
toggle bottom row

bookSingle Return Value

A single return value of a function in Python refers to returning a single object or value from a function. This type of return value has been used in previous sections.

12345
def add_numbers(a, b): return a + b result = add_numbers(3, 5) print(result) # outputs: 8
copy

The function add_numbers takes two arguments, adds them, and returns a single value — their sum. In this example, the result is stored in the variable result and printed to the console.

Note

The join() function in Python is used to join the elements of an iterable, such as a list, into a single string. Learn more about the join function here.

Tarefa
test

Swipe to show code editor

Your task is to complete the function so that it merges strings from different lists and returns the resulting string as output:

  1. You have to use arbitrary arguments because we don't know the number of lists to merge.
  2. Iterate all lists to merge the strings inside the function body.
  3. Return the resulting string using return keyword.

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!

A single return value of a function in Python refers to returning a single object or value from a function. This type of return value has been used in previous sections.

12345
def add_numbers(a, b): return a + b result = add_numbers(3, 5) print(result) # outputs: 8
copy

The function add_numbers takes two arguments, adds them, and returns a single value — their sum. In this example, the result is stored in the variable result and printed to the console.

Note

The join() function in Python is used to join the elements of an iterable, such as a list, into a single string. Learn more about the join function here.

Tarefa
test

Swipe to show code editor

Your task is to complete the function so that it merges strings from different lists and returns the resulting string as output:

  1. You have to use arbitrary arguments because we don't know the number of lists to merge.
  2. Iterate all lists to merge the strings inside the function body.
  3. Return the resulting string using return keyword.

Switch to desktopMude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo
Seção 4. Capítulo 1
Switch to desktopMude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo
We're sorry to hear that something went wrong. What happened?
some-alt