Avaliação do Tópico:
  • 0 Votos - 0 Média
  • 1
  • 2
  • 3
  • 4
  • 5
First Python Project
07/05/2017, 09:16
Resposta: #1
First Python Project
I'm attempting the first project from a book I'm trying to learn Python from.

The task was to write a function called 'collatz', with a parameter named 'number'. if number is even, then collatz should print number // 2 and return this value.
If odd then collatz should print and return 3 * number + 1.

Then the task was to write a program that lets the user input an integer, so that collatz keeps getting called with the entered argument, until the return value is 1.

I know I've printed in the loop, rather than the function, but other than that, does it seem ok?

I didn't find the right solution from the Internet.

Explainer Video Example
Encontrar todas as respostas deste usuário
Citar esta mensagem em uma resposta

Ir ao Fórum:

Usuários visualizando este tópico: 1 Visitantes

Entre em Contato | Fórum Debian | Voltar ao Topo | Voltar ao Conteúdo | Modo Leve (Arquivo) | Feeds RSS