如图7654939263682829919938373920194746647482828383
能否把代码贴出来?
# -*- coding: utf-8 -*-
def fun1(input_str: str):
if not isinstance(input_str, str):
raise ValueError("Only str parameter is allowed for this function!")
return input_str[-1]
def fun2(input_integer: int):
if not isinstance(input_integer, int):
raise ValueError("Only int parameter is allowed for this function!")
return input_integer % 2 != 0
def fun3(input_str: str):
if "." in input_str and (input_str.replace(".", "").isdigit()):
return float(input_str) ** 2
elif input_str.isdigit():
return int(input_str) ** 2
else:
return input_str * 2
input_str_fun1 = input("输入FUN1的输入参数: ")
print("FUN1的输出: 最后一个字符是'{}'".format(fun1(input_str_fun1)))
input_str_fun2 = int(input("输入FUN2的输入参数: "))
print("FUN2的输出: 是不是奇数'{}'".format(fun2(input_str_fun2)))
while True:
input_str_fun3 = input("输入FUN3的输入参数(退出请输入字母q): ")
if input_str_fun3.strip().lower() == "q":
break
else:
print("FUN3的输出: {}".format(fun3(input_str_fun3)))