函数之返回值

#函数返回值:

def singik(name, age, country = 'CN', course = 'python'):
print('学生注册信息表')
print('anme', name, '\nage', age, '\ncountry', country, '\ncourse', course)
if age > 22:
return False
else:
return True #函数一旦遇见’return‘就会返回值给外面,如果不写返回对象默认返回None 也意味着函数的终止 如果不拿结果做其他操作的话也就不需要return
meisgin = singik('alex', 22)
if meisgin:
print('可以做学生!')
else:
print('不可以当学生啦!')
print(meisgin) #这个判断是对返回接过的操作

猜你喜欢

转载自www.cnblogs.com/yuexijun/p/9993671.html