#coding:utf-8
# (1)把数据返回到函数调用处
def func():
# return 1
# return "aaabb"
return [1,2,3,4] res = func()
print(res) # 这个地方是调用处 函数名()
res = func()
print(res) print("<===>")
# (2)函数返回值不是必须,按照需求来,如果不写return 返回值,默认返回None
def func():
print(12345666)
# return 12345666
res = func()
print(res) # 打印1234567 和 自定义的return 之间没有半毛钱关系,返回值是自定义的;
res = print(1234567)
print(res) print("<=====>")
# (3) 写一个计算器
def calc(sign,num1,num2):
if sign == "+":
res = num1 + num2
elif sign == "-":
res = num1 - num2
elif sign == "*":
res = num1 * num2
elif sign == "/":
if num2 == 0:
return "抱歉,大兄弟,这个算不了"
res = num1 / num2
else:
return "你是外星来的小baby么" return res res = calc("/",5,10)
print(res)