In Question-6, Iam getting different values of v2-v1 when iam using local variable and global variable in question-4. Here is my code:

#2 Recursive Function of factorial

```
def fact(n):
if(n==1):
return(1)
elif(n>1):
return n * fact(n-1)
```

#3

```
def ratio(x,n):
return(x**n/fact(n))
print(ratio(6,3))
```

#4

```
def ratio_sum(x,N):
F = 0
for i in range(1,N+1):
F = F + ratio(x,i)
return(F+1)
print(ratio_sum(2,3))
```

#6

```
p = float(input("Enter the value of p = "))
q = float(input("Enter the value of q = "))
v1 = ratio_sum(x = p,N = 100) * ratio_sum(x = q, N = 100)
v2 = ratio_sum(x = p+q, N = 100)
print(v1,v2, v2-v1)
```

Now in #4 when i will use global variable, result of #6 will get changed

here is the code:

#4

```
F = 0
def ratio_sum(x,N):
global F
for i in range(1,N+1):
F = F + ratio(x,i)
return(F+1)
print(ratio_sum(2,3))
```

Now the result of #6 will get changed. Why this is so?