檢查的依據:奇數除2余1;偶數除2無余數
num = int(input("請輸入一個整數:")) if num % 2 == 1: print(num,"是奇數") elif num % 2 == 0: if num / 2 == 0 and user_input % 2 == 0: print (num,"既不是奇數也不是偶數") else: print(num,"是偶數")
檢查的依據:奇數除2余1;偶數除2無余數
num = int(input("請輸入一個整數:")) if num % 2 == 1: print(num,"是奇數") elif num % 2 == 0: if num / 2 == 0 and user_input % 2 == 0: print (num,"既不是奇數也不是偶數") else: print(num,"是偶數")
本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。