Even or odd · Chẵn hay lẻ
Even or odd
n is 7. Print even when n divides by 2 with no remainder, and odd otherwise.
% gives the remainder. 7 % 2 is 1, 8 % 2 is 0. Compare it with == (two equals signs) — one equals sign means store a value, and Python will tell you so.
Chẵn hay lẻ
n là 7. In even khi n chia hết cho 2 không dư, và odd trong trường hợp khác.
% cho dư. 7 % 2 là 1, 8 % 2 là 0. So sánh nó với == (hai dấu bằng) — một dấu bằng có nghĩa là lưu giá trị, và Python sẽ thông báo cho bạn biết.
n is 7. Print even when n divides by 2 with no remainder, and odd otherwise. · n là 7. In even khi n chia hết cho 2 không dư, và odd trong trường hợp khác.
Click Run to see the output here. · Nhấn Chạy để xem kết quả ở đây.