当前位置:网站首页>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 ")
边栏推荐
- 自然语言处理从小白到精通(四):用机器学习做中文邮件内容分类
- Wechat enterprise payment to change access, open quickly
- 以VMware创新之道,重塑多云产品力
- Alipay transfer system background or API interface to avoid pitfalls
- MySQL 巨坑:update 更新慎用影响行数做判断!!!
- Difference between JUnit theories and parameterized tests
- Principle and performance analysis of lepton lossless compression
- 155. Minimum stack
- RHCSA1
- Distance measuring sensor chip 4530a used in home intelligent lighting
猜你喜欢

A few years ago, I outsourced for four years. Qiu Zhao felt that life was like this

《2022年中國銀行業RPA供應商實力矩陣分析》研究報告正式啟動

【Nacos云原生】阅读源码第一步,本地启动Nacos

About the single step debugging of whether SAP ui5 floating footer is displayed or not and the benefits of using SAP ui5

Shi Zhenzhen's 2021 summary and 2022 outlook | colorful eggs at the end of the article

RHCSA1

stm32和电机开发(从架构图到文档编写)

2021.12.16-2021.12.20 empty four hand transaction records

Setting up sqli lab environment

RHCSA5
随机推荐
How can non-technical departments participate in Devops?
stirring! 2022 open atom global open source summit registration is hot!
Neural network of PRML reading notes (1)
2021-12-21 transaction record
深度长文探讨Join运算的简化和提速
10 minute fitness method reading notes (2/5)
【Nacos云原生】阅读源码第一步,本地启动Nacos
RHCSA7
跨平台(32bit和64bit)的 printf 格式符 %lld 输出64位的解决方式
Compile kernel modules separately
Laravel文档阅读笔记-mews/captcha的使用(验证码功能)
SAP ui5 objectpagelayout control usage sharing
开发者,云原生数据库是未来吗?
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é.
mysql拆分字符串做条件查询
I'm doing open source in Didi
Detailed explanation of navigation component of openharmony application development
Notes for preparation of information system project manager --- information knowledge
Actual combat simulation │ JWT login authentication
SAP SEGW 事物码里的导航属性(Navigation Property) 和 EntitySet 使用方法