Quantcast

A community for students. Sign up today!

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

knowledgegainer

  • one year ago

I need some help on this practice problem for Python.Positive root of the following equation: 34*x^2 + 68*x - 510 Recall: a*x^2 + b*x + c x1 = ( - b + sqrt ( b*b - 4*a*c ) ) / ( 2*a ) what I typed is... >>> import math >>> math.sqrt(68*68-4*34*-510) 272.0 >>> (-68+sqrt(68*68-4*34*-510))/(2*34) but I keep getting Traceback (most recent call last): File "<pyshell#2>", line 1, in <module> (-68+sqrt(68*68-4*34*-510))/(2*34) NameError: name 'sqrt' is not defined Can anyone help me with this and explain it? Thanks a lot. I am a beginner...

  • This Question is Closed
  1. salb
    • one year ago
    Best Response
    You've already chosen the best response.
    Medals 1

    what were you expecting when you wrote "(-68+sqrt(68*68-4*34*-510))/(2*34)" ?

  2. salb
    • one year ago
    Best Response
    You've already chosen the best response.
    Medals 1

    You either need to do: "from math import* if you don't want to type math.sqrt(2) and just say sqrt(2) or "from math import as m" so you could use m.sqrt(2). All I know is that how importing and using libraries works in python.

  3. knowledgegainer
    • one year ago
    Best Response
    You've already chosen the best response.
    Medals 0

    Hi thank you for your reply. When I wrote "(-68+sqrt(68*68-4*34*-510))/(2*34)" , I was expecting to get the final result.But I didn't get the final result, I got NameError: name 'sqrt' is not defined instead.

  4. salb
    • one year ago
    Best Response
    You've already chosen the best response.
    Medals 1

    "(-68+math.sqrt(68*68-4*34*-510))/(2*34)" is what you would want then in your case

  5. knowledgegainer
    • one year ago
    Best Response
    You've already chosen the best response.
    Medals 0

    Thank you so much, salb

  6. Not the answer you are looking for?
    Search for more explanations.

    • Attachments:

Ask your own question

Ask a Question
Find more explanations on OpenStudy

Your question is ready. Sign up for free to start getting answers.

spraguer (Moderator)
5 → View Detailed Profile

is replying to Can someone tell me what button the professor is hitting...

23

  • Teamwork 19 Teammate
  • Problem Solving 19 Hero
  • You have blocked this person.
  • ✔ You're a fan Checking fan status...

Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.