-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathassignment7_function.py.py
More file actions
76 lines (54 loc) · 943 Bytes
/
assignment7_function.py.py
File metadata and controls
76 lines (54 loc) · 943 Bytes
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
68
69
70
71
#question no 1
def area():
r=float(input("enter radius:"))
area=(22/7)*r*r
print(area)
return
area()
print("\n\n")
#question no 2
p=[]
def perfect():
for x in range(1,1000):
l=[]
s=0
for y in range(1,x):
if x%y==0:
l.append(y)
for a in l:
s=s+a
if s==x:
p.append(x)
perfect()
print(p)
print("\n\n")
#question no 3
def table(n):
if n>10:
return
else:
print(12*n)
table(n+1)
table(1)
print("\n\n")
#question no 4
def power(b,p):
s=1
if p==1:
return b
else:
s=b*power(b,p-1)
return s
print(power(5,5))
print("\n\n")
#question no 5
n=int(input("enter any no:"))
def fact(n):
if n==1 or n==0:
return 1
else:
b=n*fact(n-1)
return b
print("factorial is:",fact(n))
d={n:fact(n)}
print("dictionary of factorial is",d)