-
Notifications
You must be signed in to change notification settings - Fork 1
/
numberizer.py
58 lines (48 loc) · 1.34 KB
/
numberizer.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
54
55
56
57
58
"""
I'm working on writing math formulas in python, but I'm having trouble. Can you help me fix them?
Operations in Python:
addition: a+b
subtraction: a-b
negation: -a
multiplication: a*b
division: a/b
integer division: a//b (returns a/b with the decimals chopped off)
exponentiation: a**b (returns a to the b power)
"""
import numpy as np
def skware(x):
"""sometimes I want to get something times itself
"""
a= x**2
return a
def cube(x):
"""
sometimes I want something times itself, times itself
"""
return x**3
def quadratic_solver(coefficients):
"""
coefficients is a list of length 3, [a,b,c],
where a,b,c correspond to ax^2+bx+c=0
should return the two solutions to the quadratic formula
"""
complex_nums=[complex(i) for i in coefficients] #Make sure we can get all soln, not just reals
a=complex_nums[0]
b=complex_nums[1]
c=complex_nums[2]
lead = -b/a
discriminant = np.sqrt(b**2-4*a*c)
tail = discriminant/a
x1 = lead+tail
x2 = lead-tail
return x1 #How do I return both x1 and x2
def calc_circumference(r):
"""I need the circumference of a circle, given its radius, r
"""
return np.pi*r**2
def calc_area(r):
"""I need the area of a circle, given its radius, r
"""
return np.pi*r*2
#branchcheck
print(cube(2))