-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path033_Function.py
More file actions
45 lines (38 loc) · 955 Bytes
/
033_Function.py
File metadata and controls
45 lines (38 loc) · 955 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
# Define a function
def func1():
print("Hello this is function")
print("Demo function")
# Calling a Function
func1()
# Creating parameterized function
def func2(name):
print("Hello " + name)
# Calling a Function
func2("Raj")
# Setting default value for parameter
def func3(name = "Raj"):
print("I am " + name)
func3("Aatul")
func3() # Will use Raj as default value
# Passing multiple values
def func4(a, b):
print("a:", a)
print("b:", b)
func4(10,20)
# Passing multiple values as Keyword arguments
def func5(a, b):
print("a:", a)
print("b:", b)
func5(a=10,b=20)
# Passing List as a parameter
def func6(lang):
for x in lang:
print(x)
# Driver Code
list1 = ["Java","C","CPP","Android","HTML","Dart","Go"]
func6(list1)
# Define Empty Function
# Incorrect empty function in Python -> def emptyFun():
# Here is correct way to define empty function
def emptyFun():
pass