생활코딩

Coding Everybody

코스 전체목록

닫기

조건문

기본문법

Python

if True:
    print("code1")
    print("code2")
print("code3")

Ruby

if true
  puts("code1")
  puts("code2")
end
puts("code3")

실행결과

code1
code2
code3

Python | Ruby

조건문의 활용

Python

input = 11
real = 11
if real == input:
    print("Hello!")

Ruby

input = 11
real = 11
if real == input
  puts("Hello!")
end

실행결과

Hello!

Python | Ruby

else

Python

input = 11
real = 11
if real == input:
    print("Hello!")
else:
    print("Who are you?")

Ruby

input = 11
real = 11
if real == input
  puts("Hello!")
else
  puts("Who are you?")
end

실행결과

Hello!

Python | Ruby

else if

Python

input = 33
real_egoing = 11
real_k8805 = "ab"
if real_egoing == input:
  print("Hello!, egoing")
elif real_k8805 == input:
  print("Hello!, k8805")
else:
  print("Who are you?")

Ruby

input = 33
real_egoing = 11
real_k8805 = "ab"
if real_egoing == input
  puts("Hello!, egoing")
elsif real_k8805 == input
  puts("Hello!, k8805")
else
  puts("Who are you?")
end

실행결과

Who are you?

Python | Ruby

댓글

댓글 본문
버전 관리
egoing
현재 버전
선택 버전
graphittie 자세히 보기