-
Notifications
You must be signed in to change notification settings - Fork 85
/
functions.py
49 lines (31 loc) · 977 Bytes
/
functions.py
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
## why functions?(Interview Question)
# 1. to make code more readable
# 2. to make code more efficient
# 3. to make code more maintainable
# 4. to make code more reusable
# 5. to make code more extensible
# function
def welcome(msg)->str:
"""
Description: This function will show a welcome message
Return : This function will return the welcome message
"""
return msg
msg=welcome("Welcome all")
print(msg + "Please subscribe")
## function to add even and odd number
def even_odd_sum(lst):
"""
Description: This function will add even and odd number in a list
Return : This function will return the sum of even and odd number in a list
"""
even_sum=0
odd_sum=0
for i in lst:
if i%2==0:
even_sum+=i
else:
odd_sum+=i
return even_sum,odd_sum
sum1,sum2=even_odd_sum([1,2,3,45,6,677,7,8,8,54,4,3,5,6])
print(sum1,sum2)