forked from edyoda/python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions.py
More file actions
54 lines (42 loc) · 841 Bytes
/
functions.py
File metadata and controls
54 lines (42 loc) · 841 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
'''
#Multiple returns
def func(a,b):
return a + b, a * b
a,b = func(5,10)
print 'hello',a,'world',b
print 'hello %d great %d string %s' % (a,b,'great')
#Packing or Variable arguments function
def vargsFunc(*args):
for a in args:
print a,
vargsFunc(1,2,2,'hello',[1,2,2,2])
'''
'''
#default arguments
def func(age,loc='Bangalore',name='Awantik'):
print age,loc,name
func(87)
'''
'''
#UnPacking
l = ['awantik','zekelabs','python']
def packFunc(name,company,subject):
print name,company,subject
packFunc(*l)
'''
#Key words based Arguments
'''
def fun(name,address,place):
print name,address,place
fun(place='bangalore',name='awi',address='office')
'''
'''
db = {'name':'awi','age':90}
def func(name,age):
print name,age
func(**db)
'''
def func(**kwargs):
print kwargs
func(name='awi',age=40)
func(loc='bangalore',price=700)