Home >Backend Development >Python Tutorial >python programming quick start example

python programming quick start example

零下一度
零下一度Original
2017-07-03 14:21:081501browse
def collatz(number):
    while number != 1:
        if number % 2 == 0:
            number = number // 2
            print(number)
        elif number % 2 == 1:
            number = 3 * number + 1
            print(number)

print('Enter number: ')
number = int(input())
collatz(number)
<strong>-------------------------------------------<br></strong>

Enter number:
3
10
5
16
8
4
2
1

Suddenly it feels like there is nothing to comment on Yes, the tips in the book are all mentioned

The Github address of Stepping into the Pit:

I am learning, there is no high-quality code, so take your time.

 <br>

The above is the detailed content of python programming quick start example. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn