-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.py
53 lines (40 loc) · 1.53 KB
/
main.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
def hello_world():
'''Prints "Hello World!".'''
return
def sum(a, b):
'''Accepts 2 numbers as parameters, returns sum of a and b.'''
return 0
def sub(a, b):
'''Accepts 2 numbers as parameters, returns subtraction of a and b.'''
return 0
def product(a, b):
'''Accepts 2 numbers as parameters, returns product of a and b.'''
# CHALLENGE: use a for loop and your sum function to implement product
return 0
def divide(a, b):
'''Accepts 2 numbers as parameters, returns a divided by b.'''
# only pass in numbers that are divisible for sake of implementation
# CHALLENGE: use a while loop and your sub function to implement divide
return 0
def root(num):
'''Accepts a number as a parameter, returns the sqrt of num.'''
# only pass in numbers that are perfect squares for sake of implementation
# leetcode easy
# CHALLENGE: do not use any built-in Python functions
return 0;
def main():
'''The main function is where you will test all of your functions.'''
hello_world()
print("Testing sum:")
print("EXPECTED: %d, ACTUAL: %d\n" % (5, sum(2, 3)))
print("Testing sub:")
print("EXPECTED: %d, ACTUAL: %d\n" % (5, sub(7, 2)))
print("Testing product:")
print("EXPECTED: %d, ACTUAL: %d\n" % (10, product(2, 5)))
print("Testing divide:")
print("EXPECTED: %d, ACTUAL: %d\n" % (5, divide(10, 2)))
print("Testing root:")
print("EXPECTED: %d, ACTUAL: %d\n" % (5, root(25)))
# Add any additional test cases if needed
if __name__ == "__main__":
main()