5.2
def isOdd(x): if(x%2==0): return False return True x=eval(input("")) print(isOdd(x))
5.3
def isNum(s): try: s=type(eval(s)) if(s==type(1)): return True elif(s==type(1.0)): return True elif(s==type(1+j)): return True except: return False s=input("") print(isNum(s))
5.4
def multi(*n): result=1 for i in n: result=result*int(i) return result x=input("").split() lst= [int(i) for i in x] print(multi(*lst))
5.5
def isPrime(x): try: x=int(x) if x==1: return False else: for i in range(2,x): if x%i==0: return False else: return True except: print("请输入整数") x=input("") print(isPrime(x))
原文地址:https://www.cnblogs.com/sunblingbling/p/11647242.html
时间: 2024-10-29 11:27:36