-
Notifications
You must be signed in to change notification settings - Fork 0
/
quiz.py
48 lines (40 loc) · 848 Bytes
/
quiz.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
# a=1
# b=2
#
# def func():
# global b
# b = a + b
#
# func()
# print(b)
"""
Input: N = 6, Sum = 12
Output: 2.00
Divisors of N are {1, 2, 3, 6}
Sum of inverse of divisors is equal to (1/1 + 1/2 + 1/3 + 1/6) = 2.0
Input: N = 9, Sum = 13
Output: 1.44
-----------------------------------------------------------------------
def SumofInverseDivisors( N, Sum):
# Calculating the answer
ans = float(Sum)*1.0 /float(N);
# Return the answer
return round(ans,2);
# Driver code
N = 9;
Sum = 13;
print SumofInverseDivisors(N, Sum);
# This code is contributed by CrazyPro
"""
class sample():
def add(self,x,y):
return x+y
class Advanced(sample):
def Inverse(self, x, y):
return (1 / sample.add(self, x, y))
obj=sample()
sum=obj.add(2,3)
print(sum)
obj_=Advanced()
inverse=obj_.Inverse(2,3)
print(inverse)