#1 정석
n = int(input('정수 입력'))
if n % 2 == 0:
print(f'{n} is even')
else:
print(f'{n} is odd')
#2 n&1 사용하기: 홀짝구분코드
n=5
n&1 #1 #n이 홀수면 무조건 1이나옴.
n=4
n&1 #0'Python_Wiki > Python_Syntax' 카테고리의 다른 글
| list / dict comprehension (for문) (1) | 2025.07.11 |
|---|---|
| 파이썬 기본 외장 함수(Standard Library Functions) (1) | 2025.07.11 |
| 변수명 만들때 주의할 것 (1) | 2025.07.10 |
| 랜덤한 숫자를 변수에 넣기 (0) | 2025.07.09 |
| 자료형 비교: list / dict / tuple / set / bool (0) | 2025.07.08 |