返回
首页 > 生活

python偶数怎么表达

时间: 2020-09-29 16:36:00

  在python编译器中,新建一个空白的PYTHON文档;输入:

  n = float(input("Please input a number: "))

  if n % 2 == 0:

  print("This is an even")

  elif n % 2 != 0:

  print("This is an odd")

  如果输入的数字是偶数,输出的文字为“This is an even”。如果输入的数字是奇数,输出的文字为“This is an odd”。

python偶数怎么表达

  python怎么判断奇数偶数

  1、首先打开JUPYTER NOTEBOOK,新建一个空白的PYTHON文档。也可以用其它编译器的。

python偶数怎么表达

  2、输入以下内容:

  num1 = int(input("Please input a number: "))

  num2 = int(input("Please input a number: "))

  if num1 % num2 == 0:

  print("This is OK.")

  elif num1 % num2 != 0:

  print("This is NOT OK")

  如果输入的数字为偶数,文档就会返回文字"This is OK”;如果输入的数字是奇数,文档就会返回文字"This is NOT OK”。

猜你喜欢

热点推荐

版权所有 Copyright©2024 天奇生活网 版权所有

渝ICP备18012671号-3

联系邮箱:kf@tianqi.com

渝公网安备 50010302002277号