码迷,mamicode.com
首页 > 其他好文 > 详细

函数的定义与调用

时间:2018-09-25 20:43:10      阅读:156      评论:0      收藏:0      [点我收藏+]

标签:world   str   定义   表达式   函数名   方式   opp   调用函数   def   

# _*_ coding: utf-8 _*_

# 定义函数的三种方式
# 有参函数
# def function0(x):
# print(‘%s‘ % (x + 1))
#
# function0(2)

# 无参函数
# def function1():
# print(‘hello world‘)
#
# function1()

# 空函数
‘‘‘
def registration():
pass
def login():
pass
def exit():
pass
def shoppint():
pass
‘‘‘


# 函数调用的三种形式
# 1
# registration() 直接调用函数名

# 2
# def max2(x, y):
# if x > y:
# print(type(x))
# return x
# else:
# return y

#
# res = max2(7, 1) * 12 #直接在表达式中使用
# print(res)

# 3
# res = max2(max2(10,20),30)
# print(res)

函数的定义与调用

标签:world   str   定义   表达式   函数名   方式   opp   调用函数   def   

原文地址:https://www.cnblogs.com/OutOfControl/p/9703020.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!