Files
  • main.py
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
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# Created By Mosrod (Nathan R)
# (C) 2018 Nathan R, [ALL RIGHTS RESERVED]

a = float(input("a: "))
b = float(input("b: "))
c = float(input("c: "))

bnegative = b * -1
bsquared = round(b ** 2, 10)
fourac = a * c
fourac = fourac * 4
twoa = a * 2
sqrt = bsquared - fourac
sqrtcalc = sqrt ** (1 / 2)
solut1 = bnegative + sqrtcalc
solut1done = solut1 / twoa
if sqrt < 0:
    print('No Real Solutions!')
    realsolutions = 'False'
else:
    realsolutions = 'True'
print("Solution 1:", solut1done)
solut2 = bnegative - sqrtcalc
solut2done = solut2 / twoa
print("Solution 2:", solut2done)

print("""
  STEP 1: 
  {0}±√{1}-4({2})({3})
  --------------------
  {4}
  """.format(bnegative, bsquared, a, c, twoa))

fourac = abs(fourac)

if (a < 0) and (c < 0):
    sign = '-'

elif (a < 0) or (c < 0):
    sign = '+'

else:
    sign = '-'

print("""

  STEP 2:
  {0}±√{1}{2}{3}
  --------------------
  {4}

  """.format(bnegative, bsquared, sign, fourac, twoa))

print("""

  STEP 3:
  {0}±√{1}
  --------------------
  {2}

  """.format(bnegative, sqrt, twoa))

print("""

  STEP 4:
  {0}±{1}
  --------------------
  {2}
  REAL SOLUTIONS:
  
  {3}

  """.format(bnegative, sqrtcalc, twoa, realsolutions))

print("""

  STEP 5:
  {0}
  --------------------
  {1}

  {2}
  --------------------
  {1}
  
  REAL SOLUTIONS:
  {3}

  """.format(solut1, twoa, solut2, realsolutions))

print("""

  STEP 6:
  {0}

  {1}

  REAL SOLUTIONS:
  {2}
  """.format(solut1done, solut2done, realsolutions))