06 — If: make a choice
Programs choose. if runs one set of lines when a condition is true, and
else runs another when it is not.
Steps
Create
choose.nme:
run it →set ready to True if ready show GoThe line under
ifis indented. BecausereadyisTrue, it printsGo.A whole condition fits on one line with
then:
run it →if score is greater than 10 then show You wonKorean puts the condition ending on the comparison:
run it →만약에 점수가 10보다 크면 성공 말해줘Choices with
elseneed a block. The flat form closes withend:
run it →set score to 1 if score equals 1 show one else if score equals 2 show two else show other endThe Korean block uses
아니면 만약에and아니면and closes with끝.
Try it yourself
Welcome a guest only when a name exists:
set name to Mina
if name exists
show Welcome name
end
run it →What you learned
if conditionwith an indented line runs it when the condition is true.if ... then show ...is a one-line condition;만약에 ...면is Korean.else/아니면andelse if/아니면 만약에add other choices.