Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problem in a python2 file
#1
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()
                

	
Reply


Messages In This Thread
Problem in a python2 file - by sylas - Aug-07-2018, 09:36 AM
RE: Problem in a python2 file - by Larz60+ - Aug-07-2018, 09:57 AM
RE: Problem in a python2 file - by wavic - Aug-07-2018, 10:06 AM
RE: Problem in a python2 file - by sylas - Aug-07-2018, 10:08 AM
RE: Problem in a python2 file - by Gribouillis - Aug-07-2018, 10:23 AM
RE: Problem in a python2 file - by sylas - Aug-07-2018, 10:55 AM
RE: Problem in a python2 file - by Gribouillis - Aug-07-2018, 11:57 AM
RE: Problem in a python2 file - by sylas - Aug-07-2018, 01:03 PM
RE: Problem in a python2 file - by snippsat - Aug-07-2018, 01:09 PM
RE: Problem in a python2 file - by sylas - Aug-08-2018, 06:59 AM
RE: Problem in a python2 file - by buran - Aug-08-2018, 07:05 AM
RE: Problem in a python2 file - by sylas - Aug-08-2018, 07:15 AM
RE: Problem in a python2 file - by buran - Aug-08-2018, 07:32 AM
RE: Problem in a python2 file - by sylas - Aug-08-2018, 07:39 AM
RE: Problem in a python2 file - by buran - Aug-08-2018, 07:42 AM
RE: Problem in a python2 file - by sylas - Aug-08-2018, 08:54 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  python3 decoding problem but python2 OK mesbah 0 1,837 Nov-30-2019, 04:42 PM
Last Post: mesbah
  Trying to run a python2 script dagamer1991 3 2,593 Aug-12-2019, 12:33 PM
Last Post: buran
  python2.7 executables thus the system python2.7 was erroring utility.execute()? vivekm 1 1,793 May-20-2019, 11:24 AM
Last Post: vivekm
  Python2 is not supported Skaperen 2 2,210 Mar-01-2019, 07:50 PM
Last Post: stranac
  Posting zip file on HTTP network using Python2.7 deepti92 1 6,833 May-15-2018, 12:41 PM
Last Post: deepti92

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020