当前位置:网站首页>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 ")
边栏推荐
- Run, open circuit
- Leetcode20. Valid parentheses
- Notes for preparation of information system project manager --- information knowledge
- CVPR 2022 | single step 3D target recognizer based on sparse transformer
- About LDA model
- 2021-12-21 transaction record
- 谈谈我写作生涯的画图技巧
- HiEngine:可媲美本地的云原生内存数据库引擎
- 研究:数据安全工具在 60% 的情况下无法抵御勒索软件
- 实战模拟│JWT 登录认证
猜你喜欢
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é.
[cloud native] use of Nacos taskmanager task management
Transactions from January 6 to October 2022
Laravel文档阅读笔记-mews/captcha的使用(验证码功能)
Super efficient! The secret of swagger Yapi
A specific example of ABAP type and EDM type mapping in SAP segw transaction code
Taobao short video, why the worse the effect
超高效!Swagger-Yapi的秘密
Hiengine: comparable to the local cloud native memory database engine
CVPR 2022 | single step 3D target recognizer based on sparse transformer
随机推荐
The solution of outputting 64 bits from printf format%lld of cross platform (32bit and 64bit)
以VMware创新之道,重塑多云产品力
Four common problems of e-commerce sellers' refund and cash return, with solutions
Tips and tricks of image segmentation summarized from 39 Kabul competitions
Principle and performance analysis of lepton lossless compression
Notes for preparation of information system project manager --- information knowledge
SAP UI5 DynamicPage 控件介绍
[cloud native] event publishing and subscription in Nacos -- observer mode
Transactions from January 14 to 19, 2022
【云原生】Nacos-TaskManager 任务管理的使用
MySQL 巨坑:update 更新慎用影响行数做判断!!!
About the single step debugging of whether SAP ui5 floating footer is displayed or not and the benefits of using SAP ui5
DNS的原理介绍
Free testing of Taobao tmall API order and flag insertion remark interface
MySQL splits strings for conditional queries
自然语言处理从小白到精通(四):用机器学习做中文邮件内容分类
LeetCode20.有效的括号
Introduction to sap ui5 dynamicpage control
##无监控,不运维,以下是监控里常用的脚本监控
10 minute fitness method reading notes (1/5)