1.实现isOdd()函数,参数为整数,如果整数为奇数,返回True,否则返回False。
def main():
x = int(input("请输入一个整数:"))
def isOdd(x):
if x % 2 == 0:
return False
else:
return True
jo = isOdd(x)
print(jo)
main()
2.实现isNum()函数,参数为一个字符串,如果这个字符串属于整数、浮点数或复数的表示,则返回True,否则返回Flase。
x = input("请输入数字:")
def isNum(x):
try:
x = eval(x)
if type(x) == float or type(x) == int or type(x) == complex:
print('True')
else:
print('False')
except:
print('False')
isNum(x)