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?

Python学習Day26~37で学んだこと

0
Last updated at Posted at 2026-05-08

学んだこと(4/24,4/25,4/27~5/1,5/3,5/5~5/8)

paizaのランクC問題演習

  • 「range(1,N)」で1からN-1まで
  • 「print」 → 複数引数はデフォルトで半角スペース区切り
    「*」 = アンパック(展開)
    だから、s = ["A", "B", "C"] のとき
print(s)     # ['A', 'B', 'C']
print(*s)    # A B C
  • 「if !」= → 「等しくない」
  • 「"区切り文字".join(リスト)」は文字列のリストを、指定した区切り文字で連結するメソッド
  • 「end=""」 → 改行しない(通常のprint()は末尾に自動で改行(\n)が入る)
  • 「M = [0] * N」 は 0をN個並べたリストを一気に作る書き方。あとで値を入れるための「箱」を先に用意してる
  • リストのインデックス番号として「i」を使う場合は、「range(1,N+1)」でなく、「range(N)」と書いていい
  • print(f"{N:.3f}")において、「f」 → 小数(float)として表示「.3」 → 小数点以下 3桁
  • ×「f"{N:.Mf}"」 〇「f"{N:.{M}f}"」
  • 「for _ in range(回数):」は「~回だけ繰り返す」ための書き方で、変数は使わないという意味
  • 「f"{N: >3}"」はNを空白2つ分右に寄せるという意味
    {: <3} → 左寄せ
    {: ^3} → 中央寄せ
    {:0>3} → 0で埋めて右寄せ(例:005)

実際に書いたコード

N = int(input())
for i in range(1,N+1):
    
    if i%3==0 and i%5==0:
        print("Fizz Buzz")
    elif i%3==0:
        print("Fizz")
    elif i%5==0:
        print("Buzz")
    else:
        print(i)
H,W,A,B= map(int,input().split())
for i in range(H):
    for j in range(W):
        print(f"({A: >9}, {B: >9})",end="")
        if j==W-1:
            print()
        else:
            print(end=" | ")
    
    if i<H-1:
        print("="*(22*W+3*(W-1)))
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?