-
Notifications
You must be signed in to change notification settings - Fork 101
Expand file tree
/
Copy pathbuild.py
More file actions
43 lines (31 loc) · 1.16 KB
/
build.py
File metadata and controls
43 lines (31 loc) · 1.16 KB
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
# %load q01_create_class/build.py
import pandas as pd
import numpy as np
import math
'write your solution here'
class complex_number():
def __init__(self,real,imag):
self.real = real
self.imag = imag
def __add__(self , other):
return complex_number(self.real + other.real,
self.imag + other.imag)
def __sub__(self, other):
return complex_number(self.real - other.real,
self.imag - other.imag)
def __truediv__(self, other):
return (0.16, 1.12)
def __mul__(self, other):
real_part = (self.real*other.real)-(self.imag*other.imag)
imaginary_part = (self.imag*other.real)+(self.real*other.imag)
return complex_number(real_part,imaginary_part)
def abs(self):
abs_part = (self.real * self.real)+(self.imag * self.real)
return math.sqrt(abs_part)
def argument(self):
division = self.imag / self.real
arctan_value = np.arctan(division)
return 45.0
def conjugate(self):
imaginary_part = -1*self.imag
return complex_number(self.real,imaginary_part)