-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunction.py
More file actions
67 lines (43 loc) · 1.43 KB
/
Copy pathfunction.py
File metadata and controls
67 lines (43 loc) · 1.43 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
# for reusablility we uses functions .
# A function is a block of code which only runs when it is called. You can pass data, known as parameters, into a function. A function can return data as a result.
# we can wrap the code which we have to resuse in a function and use it where we want by calling it .
# functions are 2 types:
# built in
# user-defined
# there are 4 type of arguements which we can provide to the function:
# default
# keyword
# required argurements
# variable length arguements
# def average(a,b):
# c=(a+b)/2
# print (c)
# average(10,10)
def isgreat(a,b):
if(a>b):
print("1st no is greater")
else:
print("2nd no is greater")
# isgreat(1,2)
def name(a):
pass # pass means continues other program as the body of function will be defined later
# syntax of function
# def func_name():
# body
def name(a="danish"):
print(a)
# name("kartik") # these are default arguements
def helo(a,b="kalua"):
print(a,b)
# helo(a="danish ") #we must have to pass the value of a
def tup(*a): # with the use of * it will take arguement as tuple
print(type(a))
# tup(2)
def dict(**ba): # with the use of ** it will take arguement as dictionary
print(type(ba))
# dict()
# return function is used to return the value back to the calling function
def num(a):
return(a) # this return method will provides the value of a to baba keyword where we have used it
baba=num(10)
print(baba)