当前位置:网站首页>Default parameters of function & multiple methods of function parameters
Default parameters of function & multiple methods of function parameters
2022-07-05 13:01:00 【South Lake Fishing Song】
# Keyword parameters of function :
def introduce(name, gender):
""" Kindergarten self introduction """
print(f" Hello everyone , My name is :{
name}, It's a little {
gender}")
# You need to provide parameters in order , The order must not be disordered
introduce(" Xiao Ming ", " schoolboy ")
introduce(" The small white ", " girl student ")
# You can use formal parameter names = value To provide arguments
introduce(name = " Xiao Ming ", gender=" schoolboy ")
introduce( gender=" schoolboy ",name = " Xiao Ming ")
# It's fine too Positional arguments And keyword parameters coordination
introduce( " schoolboy ", gender= " Xiao Ming ")
# The default parameter of the function :
def introduce(name, gender,age = 6):
""" Kindergarten self introduction """
print(f" Hello everyone , My name is :{
name}, It's a little {
gender}, This year, {
age} Year old ")
#-------------------- Function parameters in various forms ------------------------
# When you call a function , The default parameter can be left blank
# How not to set age, So that is 6 year
introduce(" Xiao Ming ", " schoolboy ")
# If you pass a new value , Override default
introduce(" Xiao Ming ", " schoolboy ",age=5)
introduce(" Xiao Ming ", " schoolboy ",5)
# Position arguments need to be in order 、 The keyword parameter uses key=value You can change the order 、 Default parameters can be left blank
introduce(age=8,name=" Xiao Ming ", gender=" schoolboy ")
边栏推荐
- Taobao short videos are automatically released in batches without manual RPA open source
- 946. Verify stack sequence
- 函数的默认参数&函数参数的多种方法
- 关于 SAP UI5 floating footer 显示与否的单步调试以及使用 SAP UI5 的收益
- Detailed explanation of navigation component of openharmony application development
- Tips and tricks of image segmentation summarized from 39 Kabul competitions
- CF:A. The Third Three Number Problem【关于我是位运算垃圾这个事情】
- SAP UI5 DynamicPage 控件介紹
- Alipay transfer system background or API interface to avoid pitfalls
- SAP UI5 视图里的 OverflowToolbar 控件
猜你喜欢
SAP SEGW 事物码里的 ABAP Editor
Introduction to the principle of DNS
[Nacos cloud native] the first step of reading the source code is to start Nacos locally
【云原生】Nacos中的事件发布与订阅--观察者模式
SAP UI5 视图里的 OverflowToolbar 控件
Transactions from December 29, 2021 to January 4, 2022
PyCharm安装第三方库图解
函数传递参数小案例
I met Tencent in the morning and took out 38K, which showed me the basic smallpox
自然语言处理系列(一)入门概述
随机推荐
SAP SEGW 事物码里的 Association 建模方式
MySQL splits strings for conditional queries
将函数放在模块中
[cloud native] use of Nacos taskmanager task management
Free testing of Taobao tmall API order and flag insertion remark interface
About the single step debugging of whether SAP ui5 floating footer is displayed or not and the benefits of using SAP ui5
946. 验证栈序列
Notes for preparation of information system project manager --- information knowledge
Run, open circuit
谈谈我写作生涯的画图技巧
Four common problems of e-commerce sellers' refund and cash return, with solutions
Hiengine: comparable to the local cloud native memory database engine
Rasa Chat Robot Tutorial (translation) (1)
Shi Zhenzhen's 2021 summary and 2022 outlook | colorful eggs at the end of the article
RHCSA5
Introduction to the principle of DNS
《2022年中國銀行業RPA供應商實力矩陣分析》研究報告正式啟動
超高效!Swagger-Yapi的秘密
A few years ago, I outsourced for four years. Qiu Zhao felt that life was like this
《信息系统项目管理师》备考笔记---信息化知识