-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunc.py
More file actions
29 lines (22 loc) · 974 Bytes
/
func.py
File metadata and controls
29 lines (22 loc) · 974 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
# -------------------------------------- Task 1 -----------------------------------
def add(x, y):
return x + y
# TODO: Add definitions of sub(), div(), mult(), exp(), as well as neg() and sqrt().
# neg() should return the negation of the given number, and sqrt() should
# return the square root of the given number.
def neg(x):
a = 2 + 13 # fill here
def sqrt(x):
... # fill here
# -------------------------------------- Task 2 -----------------------------------
# TODO: Implement the quadratic formula using *only* the functions defined here.
# Do not use arithmetic operators directly.
# You're allowed to define other functions.
a = 1
b = -3
c = 1
x1 = ... # TODO: write a code to compute the first root of the quadratic equation
x2 = ... # TODO: then do the same for the second root
# Note: Make sure to remove the ellipsis (...) when you're writing your code
print("First root:" + str(x1))
print("Second root:" + str(x2))