스크립트
[코딩테스트 입문] 짝수와 홀수
변군이글루
2022. 11. 30. 13:25
반응형
짝수와 홀수
1안) solution.py
def solution(num):
answer = ''
if num % 2 == 0:
answer = str("Even")
else:
answer = str("Odd")
return answer
2안) solution.py
def solution(num):
answer = ''
if num % 2 == 1:
answer = str("Odd")
else:
answer = str("Even")
return answer
출처 - 프로그래머스(코딩테스트 연습) : https://school.programmers.co.kr/learn/courses/30/lessons/12937
파이션 if else
a = 200
b = 33
if b > a:
print("b is greater than a")
elif a == b:
print("a and b are equal")
else:
print("a is greater than b")
a is greater than b
참고URL
- w3schools : https://www.w3schools.com/python/gloss_python_else.asp
- w3schools : https://www.w3schools.com/python/python_operators.asp
728x90
반응형