-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathfunc.py
More file actions
44 lines (37 loc) · 738 Bytes
/
func.py
File metadata and controls
44 lines (37 loc) · 738 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
def hello(name = "Nikifor"):
"""
Very useful function
"""
greet = "Hello, " + str(name)
print(greet)
return greet
def iterPower(base, exp):
'''
base: int or float.
exp: int >= 0
returns: int or float, base^exp
'''
result = base
if exp == 0:
return 1
else:
for i in range(1, exp):
result *= base
print(result)
return result
def recurPower(base, exp):
'''
base: int or float.
exp: int >= 0
returns: int or float, base^exp
'''
# Your code here
if exp == 1:
return base
elif exp == 0:
return 1
else:
return base*recurPower(base, exp-1)
hello()
hello("Peter")
iterPower(2, 4)