1 def ji_ou(n): 2 if n & 1 == 1: 3 print("n is ji shu") 4 else: 5 print("n is ou shu") 6 7 if __name__ == "__main__": 8 n = int(input("enter the num:")) 9 ji_ou(n)
數字n 和 1 相與,如果結果為1,則為奇數;否則為偶數。
正數和負數皆可
1 def ji_ou(n): 2 if n & 1 == 1: 3 print("n is ji shu") 4 else: 5 print("n is ou shu") 6 7 if __name__ == "__main__": 8 n = int(input("enter the num:")) 9 ji_ou(n)
數字n 和 1 相與,如果結果為1,則為奇數;否則為偶數。
正數和負數皆可
本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。