forked from harshulmca17/MCA-101-_2017
-
Notifications
You must be signed in to change notification settings - Fork 0
/
increment.py
55 lines (37 loc) · 1.19 KB
/
increment.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
50
51
52
53
54
def increment(x):
'''
Objective : To compute the increment of given number.
Input Variables :
x : The number inputted by user.
Return value : Incremented value of given number.
'''
#Approach : Return x+1
x += 1
return x
def sum(x,y):
'''
Objective : To calculate the sum of given two numbers.
Input Variables :
x : First number inputted by user.
y : First number inputted by user.
Return value : Sum of given two numbers.
'''
#Approach : Use increment function to compute the sum of given two numbers.
assert x >=0 and y >= 0
if(y==0):
return x
else:
return sum(increment(x),y-1)
def main():
'''
Objective : making use of sum function
Input Variables :
x : A number inputted for incrementation
y : A number inputted for incrementation
'''
#Appoach : to compute sum using incrementation and recursion
x = int(input("Enter value of X: "))
y = int(input("Enter value of Y: "))
print("Sum of the values : ", sum(x,y))
if __name__ == '__main__':
main()