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?

九九表作成

Last updated at Posted at 2023-11-14

前回に続いてこちらも。
https://paiza.jp/works/mondai/stdout_primer/stdout_primer__2dim_array_step3

九九表を作れという問題。
まあ、phpでもあったfor複数ループをPythonでもやればいいだけ。
range関数が0からはじまるのでそこらへんの調整は必要だけど。

for i in range(9):
    for j in range(9):
        print((j+1)*(i+1),end="")
        if (j+1) % 9 == 0:
            print()
        else:
            print(" ",end="")

めんどい場合は、一応こちらのrange関数でもできる(覚えよう)
むしろこっちのほうがロジックがわかりやすいか?

for i in range(1, 10):
    for j in range(1, 10):
        if j == 9:
            print(i * j)
        else:
            print(i * j, end=" ")

0
0
0

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?