0
1

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文法まとめ【if】

Last updated at Posted at 2024-04-26

はじめに

Pythonの基礎的なことをまとめています。
Google Colabで実行できます。
Colabの使い方(Python.jp)

条件分岐

サンプル
number = 5

if number % 2 == 0:
  print('偶数です。')
else:
  print('奇数です。')

変数numberが偶数か判定するコードです。

if 条件式:
  処理

が基本形です。

%は計算結果のあまりを返します。
==は、左辺と右辺が等しいかどうかを判定します。

おわり

お役に立てたら幸いです。

0
1
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
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?