python--function parameter types

Source: Internet
Author: User

Python function parameters are divided into 3 main forms:

1. Position or keyword Parameters

2. Any number of positional parameters

3. Any number of keyword parameters

def fun7 (a,b,c): Print a,b,cfun7 (1,8,9) Fun7 (a= the, c= -, b= About) Fun7 (a="Soyo", c= -, b="Soyosoyo") def fun8 (str2,*num): Print"The string is:"+str2 Print"The numbers are:", NumreturnNUMQ=FUN8 ("Soyo5",1,2,6,8) forIinchq:print idef fun9 (STR3,*num1,**Kwargs): Print"str3="+STR3 Print"the numbers within the tuple are:", NUM1 print"The dictionary is:", KwargsreturnKWARGSA1=fun9 ("soyo100",1,5,9, name="Millet", value= the) Keys=A1.keys () print keys forIinchKeys:print A1[i]

Results:

1 8 9
89 99 70
Soyo Soyosoyo 100
The string is: Soyo5
Numbers are: (1, 2, 6, 8)
1
2
6
8
str3=soyo100
The numbers within the tuple are: (1, 5, 9)
The dictionary is: {' name ': ' \xe5\xb0\x8f\xe7\xb1\xb3 ', ' Value ': 88}
[' Name ', ' value ']
Millet
88

python--function parameter types

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.