[PYTHON] Julia quick note [05] if statement

if statement (example of writing)

note05



if x > y
    println("x is greater than y.")
elseif x == y
    println("x is equal to y.")
else
    println("x is less than y.")
end

◆ Multiple conditions(&&, ||)
 if x > 0 && y > 0
     println("x and y is greater than 0.")
 elseif x == 0 || y == 0
     println("x or y is 0.")
 end

◆ Ternary operator
 if x > 0 ? true : false

Commentary

-The major difference from Python is that there is ** end **. You need to start with if and end with end. ・ Else if and else are not required. You can add it if necessary. -The ** ternary operator ** is an operator in the form of "a? B: c" that returns b if the evaluation result of a is true and c if it is false.

Lottery

Julia Quick Look Note [01] How to use variables and constants Julia Quick Look Note [02] Arithmetic Expressions, Operators [Julia Quick Note [03] Complex Numbers] (https://qiita.com/ttabata/items/225c77a4d71fafc3e482) Julia Quick Look Note [04] Regular Expression [Julia quick note [05] if statement] (https://qiita.com/ttabata/items/4f0bcff1e32f60402dfb)

(* We will continue to increase the content)

Related information

: paperclip: Julia --Official page https://julialang.org/

: paperclip: Julia --Japanese official document https://julia-doc-ja.readthedocs.io/ja/latest/index.html

: paperclip: First time Julia and installation (Windows & Linux) https://qiita.com/ttlabo/items/b05bb43d06239f968035

:paperclip: Julia - Mathematics https://docs.julialang.org/en/v1/base/math/

Opinions etc.

If you have any opinions or corrections, please let us know.

Recommended Posts

Julia quick note [05] if statement
Julia Quick Note [03] Complex Numbers
Julia Quick Note [06] Loop processing
Julia Quick Note [10] Function (2) Application
Julia Quick Note [04] Regular Expression
Julia Quick Note [09] Function (1) Basics
Julia Quick Note [07] try, catch, finally
Julia Quick Note [02] Arithmetic formulas, operators
Python if statement
[Python] if statement
Julia Quick Note [22] Calling Python functions and Python modules
Python basic if statement
Julia Quick Note [01] How to use variables and constants
Julia Quick Note [08] Variable Type (Int, Float, Bool, Char, String)
Addition with Python if statement
About 2-variable, 4-branch if statement
[python] Correct usage of if statement
[Python] File operation using if statement