Sign Up

Have an account? Sign In Now

Sign In

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

Sorry, you do not have a permission to ask a question, You must login to ask question.

Forgot Password?

Need An Account, Sign Up Here
Sign InSign Up

ErrorCorner

ErrorCorner Logo ErrorCorner Logo

ErrorCorner Navigation

  • Home
  • Contact Us
  • About Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Contact Us
  • About Us
Home/ Questions/Q 471
Next
Answered
Kenil Vasani
Kenil Vasani

Kenil Vasani

  • 646 Questions
  • 567 Answers
  • 77 Best Answers
  • 26 Points
View Profile
  • 3
Kenil Vasani
Asked: December 11, 20202020-12-11T20:38:16+00:00 2020-12-11T20:38:16+00:00In: Python

TypeError: ufunc ‘multiply’ did not contain a loop with signature matching types dtype(‘S32’) dtype(‘S32’) dtype(‘S32’)

  • 3

I am new to coding but I am trying to create a really simple program that will basically plot a line. The user will input values for v and a then v and a and x will determine y. I attempted to do this with this:

x = np.linspace(0., 9., 10)
a = raw_input('Acceleration =')
v = raw_input('Velocity = ')
y=v*x-0.5*a*x**2.

basically this will represent a parabola where v is velocity, a is acceleration and x is time. But, I keep getting this error:

TypeError: ufunc 'multiply' did not contain a loop with signature matching types dtype('S32'
) dtype('S32') dtype('S32')
matplotlibpythontypeerror
  • 1 1 Answer
  • 9 Views
  • 0 Followers
  • 0
Answer
Share
  • Facebook

    1 Answer

    • Voted
    1. Rohit Patel

      Rohit Patel

      • 0 Questions
      • 98 Answers
      • 0 Best Answers
      • 0 Points
      View Profile
      Best Answer
      Rohit Patel
      2020-12-11T20:35:26+00:00Added an answer on December 11, 2020 at 8:35 pm

      From the documentation of raw_input:

      The function then reads a line from input, converts it to a string (stripping a trailing newline), and returns that.

      So what happens is that you try to multiply a string with a float, something like y="3" * x - 0.5 * "3" *x**2, which is not defined.

      The easiest way to circumvent this is to cast the input string to float first.

      x = np.linspace(0., 9., 10)
      a = float(raw_input('Acceleration ='))
      v = float(raw_input('Velocity = '))
      y=v*x-0.5*a*x**2
      

      Mind that if you’re using python 3, you’d need to use inputinstead of raw_input,

      a = float(input('Acceleration ='))
      
      • 7
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp

    You must login to add an answer.

    Forgot Password?

    Sidebar

    Ask A Question
    • Popular
    • Kenil Vasani

      SyntaxError: invalid syntax to repo init in the AOSP code

      • 5 Answers
    • Kenil Vasani

      xlrd.biffh.XLRDError: Excel xlsx file; not supported

      • 3 Answers
    • Kenil Vasani

      Homebrew fails on MacOS Big Sur

      • 3 Answers
    • Kenil Vasani

      runtimeError: package fails to pass a sanity check for numpy ...

      • 3 Answers
    • Kenil Vasani

      Could not find tools.jar. Please check that /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home contains ...

      • 2 Answers

    Explore

    • Most Answered
    • Most Visited
    • Most Voted
    • Random

    © 2020-2021 ErrorCorner. All Rights Reserved
    by ErrorCorner.com