0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Python3 文系学生の独学メモ① 関数定義

0
Last updated at Posted at 2020-01-12

1から100まで表示するプログラム

x = 0
while(x < 100):
    x += 1
    print(x)

defで定義して同様のプログラムを書く

def xplus(x):
    return x + 1

a = 0

while(a < 100):
    a = xplus(a)
    print(a)

上記のプログラムについてteratailで質問しています。
https://teratail.com/questions/234617

コラッツの問題(奇数なら+1、偶数なら÷2...を解く)

x = int(input())
while(x > 1):
    if x % 2 == 0:
        x //= 2
        print(x)
    else:
        x += 1
        print(x)

上記のプログラムについてteratailで質問しています。
https://teratail.com/questions/234626

0
0
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?