当前位置:网站首页>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 ")
边栏推荐
- SAP UI5 FlexibleColumnLayout 控件介绍
- MySQL splits strings for conditional queries
- Le rapport de recherche sur l'analyse matricielle de la Force des fournisseurs de RPA dans le secteur bancaire chinois en 2022 a été officiellement lancé.
- Laravel文档阅读笔记-mews/captcha的使用(验证码功能)
- Discussion on error messages and API versions of SAP ui5 getsaplogonlanguage is not a function
- 《信息系统项目管理师》备考笔记---信息化知识
- Shi Zhenzhen's 2021 summary and 2022 outlook | colorful eggs at the end of the article
- Reshape the power of multi cloud products with VMware innovation
- RHCSA3
- Simply take stock reading notes (2/8)
猜你喜欢
10 minute fitness method reading notes (5/5)
A specific example of ABAP type and EDM type mapping in SAP segw transaction code
SAP UI5 视图里的 OverflowToolbar 控件
Taobao short videos are automatically released in batches without manual RPA open source
SAP self-development records user login logs and other information
Taobao order amount check error, avoid capital loss API
阿里云SLB负载均衡产品基本概念与购买流程
Lepton 无损压缩原理及性能分析
太方便了,钉钉上就可完成代码发布审批啦!
Concurrent performance test of SAP Spartacus with JMeter
随机推荐
Simply take stock reading notes (3/8)
Vonedao solves the problem of organizational development effectiveness
2021.12.16-2021.12.20 empty four hand transaction records
Didi open source Delta: AI developers can easily train natural language models
stirring! 2022 open atom global open source summit registration is hot!
SAP SEGW 事物码里的 ABAP Editor
RHCSA2
The solution of outputting 64 bits from printf format%lld of cross platform (32bit and 64bit)
自然语言处理从小白到精通(四):用机器学习做中文邮件内容分类
SAP SEGW 事物码里的 Association 建模方式
以VMware创新之道,重塑多云产品力
Natural language processing series (I) introduction overview
2021-12-22 transaction record
Four common problems of e-commerce sellers' refund and cash return, with solutions
MySQL splits strings for conditional queries
【云原生】Nacos-TaskManager 任务管理的使用
Run, open circuit
函数传递参数小案例
#yyds干货盘点# 解决名企真题:搬圆桌
SAP UI5 DynamicPage 控件介绍