# Python CodeRecipe|ifの使い方

Home Python Keywords

# ifの例1

Print "YES" if x larger than 3:

    x = 5if x > 3:  
    print("YES")

# ifの定義及び使い方

if関数は、条件を作成するために使用します。 ステートメント(if文)が含まれており、 conditionはTrueです。 else関数を使用して、 conditionがFalseの場合、次の例を参照してください。

# ifの例2

Print "YES" if x is larger than 6, otherwise print "NO":

    x = 5if x > 6:  
    print("YES")else:  print("NO")

Related Pages The else keyword. The elif keyword. Read more about conditional statements in our Python Conditions Tutorial.

Home Python Keywords