예제 풀이 사전 정보 (홀짝찾기)
## Odd or Even
# UPDATE
We've moved away from repl.it for coding exercises.
Check out the new exercises on Coding Rooms with automated submissions.
Login to your Udemy course and head over to the link below to get the sign up link:
[Click here](https://www.udemy.com/course/100-days-of-code/learn/lecture/17825914#questions)
# Instructions
Write a program that works out whether if a given number is an odd or even number.
Even numbers can be divided by 2 with no remainder.
e.g. 86 is **even** because 86 ÷ 2 = 43
43 does not have any decimal places. Therefore the division is clean.
e.g. 59 is **odd** because 59 ÷ 2 = 29.5
29.5 is not a whole number, it has decimal places. Therefore there is a remainder of 0.5, so the division is not clean.
The **modulo** is written as a percentage sign (%) in Python. It gives you the remainder after a division.
e.g.
6 ÷ 2 = 3 with no remainder.
```
6 % 2 = 0
```
5 ÷ 2 = 2 x **2** + 1, remainder is 1.
```
5 % 2 = 1
```
14 ÷ 4 = 3 x **4** + 2, remainder is 2.
```
14 % 4 = 2
```
**Warning** your output should match the Example Output format exactly, even the positions of the commas and full stops.
# Example Input 1
```
43
```
# Example Output 1
```
This is an odd number.
```
# Example Input 2
```
94
```
# Example Output 2
```
This is an even number.
```
e.g. When you hit **run**, this is what should happen:

# Hint
1. All even numbers can be divided by 2 with 0 remainder.
2. Try some using the modulo with some odd numbers e.g.
```
3 % 2
```
```
5 % 2
```
```
7 % 2
```
Then try using the modulo with some even numbers e.g.
```
4 % 2
```
```
6 % 2
```
```
8 % 2
```
See what's in common each time.
혼자 풀이
# 🚨 Don't change the code below 👇
number = int(input("Which number do you want to check? "))
# 🚨 Don't change the code above 👆
#Write your code below this line 👇
if number % 2 == 1:
print("This is an odd number.")
elif number % 2 == 0 :
print("This is an even number")
else:
print("error!")
개선 : 정수는 2로 나누면 나머지가 0이나 1밖에 없어서 elif 까지 사용할 필요가 없었다. 간결한 코드 작성을 한다면
# 🚨 Don't change the code below 👇
number = int(input("Which number do you want to check? "))
# 🚨 Don't change the code above 👆
#Write your code below this line 👇
if number % 2 == 1:
print("This is an odd number.")
else:
print("This is an even number")