-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpyalgebra.py
81 lines (47 loc) · 1.85 KB
/
pyalgebra.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# making sure that the file runs by importing only
if __name__ == 'pyalgebra':
# in this library we are solving the equation of x + y = z,x - y = z,x * y = z and z / y = z when both x and y are filled then raise a type error and if x is filled or y is filled then calculate the answer of the equation and if neither x is filled nor y is filled then raise a type error
def solve_addition_equation(x,y,z):
if x == 0:
x_value = z - y
return x_value
if y == 0:
y_value = z - x
return y_value
if x != 0 and y != 0:
raise TypeError('You can only fill x number or y number,you cannot fill both x and y')
if x == 0 and y == 0:
raise TypeError('You need to fill x or y')
def solve_substraction_equation(x,y,z):
if x == 0:
x_value = z + y
return x_value
if y == 0:
y_value = x - z
return y_value
if x != 0 and y != 0:
raise TypeError('You can only fill x number or y number,you cannot fill both x and y')
if not x != 0 and y != 0:
raise TypeError('You need to fill x or y')
def solve_multiplication_equation(x,y,z):
if x == 0:
x_value = z / y
return x_value
if y == 0:
y_value = z / x
return y_value
if x != 0 and y != 0:
raise TypeError('You can only fill x number or y number,you cannot fill both x and y')
if not x != 0 and y != 0:
raise TypeError('You need to fill x or y')
def solve_division_equation(x,y,z):
if x == 0:
x_value = z * y
return x_value
if y == 0:
y_value = z / x
return y_value
if x != 0 and y != 0:
raise TypeError('You can only fill x number or y number,you cannot fill both x and y')
if not x != 0 and y != 0:
raise TypeError('You need to fill x or y')