当前位置:网站首页>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 ")
边栏推荐
- leetcode:221. 最大正方形【dp状态转移的精髓】
- NLP engineer learning summary and index
- Association modeling method in SAP segw transaction code
- 使用 jMeter 对 SAP Spartacus 进行并发性能测试
- Taobao product details API | get baby SKU, main map, evaluation and other API interfaces
- A deep long article on the simplification and acceleration of join operation
- It's too convenient. You can complete the code release and approval by nailing it!
- Tips and tricks of image segmentation summarized from 39 Kabul competitions
- 【Nacos云原生】阅读源码第一步,本地启动Nacos
- SAP UI5 FlexibleColumnLayout 控件介绍
猜你喜欢

Introduction to sap ui5 flexiblecolumnlayout control

Annotation problem and hidden Markov model

开发者,云原生数据库是未来吗?

Introduction aux contrôles de la page dynamique SAP ui5

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é.

Transactions from December 29, 2021 to January 4, 2022

使用 jMeter 对 SAP Spartacus 进行并发性能测试

研究:数据安全工具在 60% 的情况下无法抵御勒索软件

What if wechat is mistakenly sealed? Explain the underlying logic of wechat seal in detail

《信息系统项目管理师》备考笔记---信息化知识
随机推荐
946. Verify stack sequence
Why is your next computer a computer? Explore different remote operations
CVPR 2022 | single step 3D target recognizer based on sparse transformer
How to connect the API interface of Taobao open platform (super detailed)
#yyds干货盘点# 解决名企真题:搬圆桌
Four common problems of e-commerce sellers' refund and cash return, with solutions
Insmod prompt invalid module format
Transactions from December 29, 2021 to January 4, 2022
Pinduoduo flag insertion remarks API
奔跑,开路
SAP UI5 DynamicPage 控件介绍
Yyds dry inventory JS intercept file suffix
155. Minimum stack
SAP UI5 ObjectPageLayout 控件使用方法分享
Didi open source Delta: AI developers can easily train natural language models
stm32和电机开发(从架构图到文档编写)
RHCAS6
我在滴滴做开源
《2022年中国银行业RPA供应商实力矩阵分析》研究报告正式启动
简单上手的页面请求和解析案例