Python Forum
Basic Boolean homework help
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Basic Boolean homework help
#7
A follow-up question on the same homework.

import numpy as np


a = input('what is the coefficient for a? ')
b = input('what is the coefficient for b? ')
c = input('what is the coefficient for c? ')

# calculate the discriminant
d = (b**2)-(4*a*c)

sol1 = (-b-np.sqrt(d))/(2*a)
sol2 = (-b+np.sqrt(d))/(2*a)

if d > 0.:
    print('There are two real roots which are ', sol1, 'and', sol2)
elif d == 0.:
    print('There is one real root which is ', sol1)
else:
    print ('There are no real roots ')
    
    
Why does this not work??
Reply


Messages In This Thread
Basic Boolean homework help - by StillAnotherDave - Nov-22-2019, 09:14 PM
RE: Basic Boolean homework help - by scidam - Nov-22-2019, 11:33 PM
RE: Basic Boolean homework help - by ibreeden - Nov-24-2019, 10:06 AM
RE: Basic Boolean homework help - by scidam - Nov-25-2019, 08:45 AM
RE: Basic Boolean homework help - by StillAnotherDave - Nov-27-2019, 10:08 AM
RE: Basic Boolean homework help - by perfringo - Nov-27-2019, 10:17 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Homework advice - Boolean function, whole-word values musicjoeyoung 4 3,362 May-07-2020, 06:10 PM
Last Post: musicjoeyoung

Forum Jump:

User Panel Messages

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