Aug-07-2018, 09:36 AM
Hi all ! Because I installed "click" being in python2, I can import "click" only on python2. I cannot use 3.6 for this file. My problem appears at line 19.
import click
import math
print("solver.py in python2.7")
class Solver:
def demo(self):
print("Resolve second degree equation. Enter the coefficients(numbers): a,b,c")
text = raw_input(' Are you ready: y/n ? ')
print('you entered: ', text)
text = "y"
while (text == 'y'):
# while True:
a = float(input("a "))
b = float(input("b "))
c = float(input("c "))
d = b ** 2 - 4 * a * c
if d >= 0:
disc = math.sqrt(d)
root1 = (-b + disc) / (2 * a)
root2 = (-b - disc) / (2 * a)
print(root1, root2)
else:
print('This equation has no roots')
print('do you want to begin again for another equation ? ')
#text = raw_input(' y/n ? ')
#print("you entered: ", text)
click.echo('Do you agree ? y/n ', nl=False)
text= click.getchar()
click.echo()
if text == b'y':
click.echo('We wiil continue')
elif text == b'n':
click.echo('Abort!')
exit()
else:
click.echo('Invalid input ! ')
exit()
Solver().demo()
