Unsupported operand types 'NoneType'

Redoholic

I am very new to Python, and I'm trying to create a software that calculates a series of equations and I keep running into an error.

This is the code:

import math

x_i = 1
dt = 0.01
k = 11.5
r_out = 0.889
w = 0.03175
dL = 30
m = float(input("Enter m: "))
v_i = float(input("Enter v_i: "))

t = [0]
x = [x_i]
v = [v_i]
Fc = []

while (v_i > 0):
 
    Fc.append(k*v_i**2*math.cos(math.atan(30/x_i)))/2*(math.sqrt(r_out**2-(w/math.pi)*math.sqrt(x_i**2+dL**2)))
    x.append(x_i+v_i*Dr+0.5*(-Fc_I/m)*dt)
    v.append(v_i-(k*v_i**2*math.cos(math.atan(30/x_i)))/2*(math.sqrt(r_out**2-(w/math.pi)*math.sqrt(x_i**2+dL**2))))
    v_i = v_i + 1
    t.append(dt*(t+1))

My goal is that the code runs these equations until v_i equals 0, while populating the lists with the relevant results, then throwing all the information into a graph once the while loop is done.

However, after inserting m and v_i, I get an error that says:

line 19, in <module>
    FC.append(k*v_i**2*math.cos(math.atan(30/x_i)))/2*(math.sqrt(r_out**2-(w/math.pi)*math.sqrt(x_i**2+dL**2)))
TypeError: unsupported operand type(s) for /: 'NoneType' and 'int'

I'm a bit stuck at the moment and I can't seem to figure out how to fix this error.

Ann Zen

This line:

C.append(k*v_i**2*math.cos(math.atan(30/x_i)))/2*(math.sqrt(r_out**2-(w/math.pi)*math.sqrt(x_i**2+dL**2)))

You are appending a value to C, and then using the / operator on the append() call.

list.append() returns None, hence the error. Try this instead:

C.append(k*v_i**2*math.cos(math.atan(30/x_i))/2*(math.sqrt(r_out**2-(w/math.pi)*math.sqrt(x_i**2+dL**2))))

P.S. PEP-8 is recommended:

C.append(k * v_i ** 2 * math.cos(math.atan(30 / x_i)) / 2 * (math.sqrt(r_out ** 2 - (w / math.pi) * math.sqrt(x_i ** 2 + dL ** 2))))

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Django unsupported operand types

From Dev

Unsupported operand type(s) for *: 'NoneType' and 'NoneType' (Python)

From Dev

unsupported operand types for //: 'str', 'int'

From Dev

unsupported operand types for * : 'float' and 'decimal'

From Dev

unsupported operand type(s) for +=: 'NoneType' and 'list'

From Dev

unsupported operand type(s) for +: 'NoneType' and 'int'

From Dev

TypeError: unsupported operand type(s) for *: 'NoneType' and 'int'

From Dev

TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'

From Dev

TypeError: unsupported operand int and NoneType? Python

From Dev

TypeError: unsupported operand type(s) for +: 'int' and 'NoneType'

From Dev

TypeError: unsupported operand type(s) for %: 'NoneType' and 'int'

From Dev

TypeError: unsupported operand type(s) for %: 'NoneType' and 'int'

From Dev

Unsupported operand type(s) for +: 'NoneType' and 'str' and 'int'

From Dev

TypeError: unsupported operand type(s) for +: 'NoneType' and 'int'

From Dev

TypeError: unsupported operand type(s) for *: 'int' and 'NoneType'

From Dev

TypeError: unsupported operand type(s) for /: 'NoneType' and 'float'

From Dev

I keep getting a " TypeError: unsupported operand type(s) for -: 'NoneType' and 'NoneType' "

From Dev

Unsupported operand types for bitwise exclusive OR in Python

From Dev

Python Error: unsupported operand type(s) for +: 'int' and 'NoneType'

From Dev

Having issues with formatters: "unsupported operand type(s) for %: 'NoneType' and 'tuple'"

From Dev

Python TypeError: unsupported operand type(s) for /: 'NoneType' and 'float'

From Dev

Python TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'

From Dev

Keras reports TypeError: unsupported operand type(s) for +: 'NoneType' and 'int'

From Dev

Python Error: unsupported operand type(s) for +: 'int' and 'NoneType'

From Dev

Python error: unsupported operand type(s) for -: 'float' and 'NoneType'

From Dev

TypeError: unsupported operand type(s) for %: 'NoneType' and 'tuple' with random generator?

From Dev

Having issues with formatters: "unsupported operand type(s) for %: 'NoneType' and 'tuple'"

From Dev

TypeError: unsupported operand type(s) for +=: 'float' and 'NoneType' in Python 3

From Dev

TypeError: unsupported operand type(s) for +: 'NoneType' and 'int' in while loop

Related Related

  1. 1

    Django unsupported operand types

  2. 2

    Unsupported operand type(s) for *: 'NoneType' and 'NoneType' (Python)

  3. 3

    unsupported operand types for //: 'str', 'int'

  4. 4

    unsupported operand types for * : 'float' and 'decimal'

  5. 5

    unsupported operand type(s) for +=: 'NoneType' and 'list'

  6. 6

    unsupported operand type(s) for +: 'NoneType' and 'int'

  7. 7

    TypeError: unsupported operand type(s) for *: 'NoneType' and 'int'

  8. 8

    TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'

  9. 9

    TypeError: unsupported operand int and NoneType? Python

  10. 10

    TypeError: unsupported operand type(s) for +: 'int' and 'NoneType'

  11. 11

    TypeError: unsupported operand type(s) for %: 'NoneType' and 'int'

  12. 12

    TypeError: unsupported operand type(s) for %: 'NoneType' and 'int'

  13. 13

    Unsupported operand type(s) for +: 'NoneType' and 'str' and 'int'

  14. 14

    TypeError: unsupported operand type(s) for +: 'NoneType' and 'int'

  15. 15

    TypeError: unsupported operand type(s) for *: 'int' and 'NoneType'

  16. 16

    TypeError: unsupported operand type(s) for /: 'NoneType' and 'float'

  17. 17

    I keep getting a " TypeError: unsupported operand type(s) for -: 'NoneType' and 'NoneType' "

  18. 18

    Unsupported operand types for bitwise exclusive OR in Python

  19. 19

    Python Error: unsupported operand type(s) for +: 'int' and 'NoneType'

  20. 20

    Having issues with formatters: "unsupported operand type(s) for %: 'NoneType' and 'tuple'"

  21. 21

    Python TypeError: unsupported operand type(s) for /: 'NoneType' and 'float'

  22. 22

    Python TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'

  23. 23

    Keras reports TypeError: unsupported operand type(s) for +: 'NoneType' and 'int'

  24. 24

    Python Error: unsupported operand type(s) for +: 'int' and 'NoneType'

  25. 25

    Python error: unsupported operand type(s) for -: 'float' and 'NoneType'

  26. 26

    TypeError: unsupported operand type(s) for %: 'NoneType' and 'tuple' with random generator?

  27. 27

    Having issues with formatters: "unsupported operand type(s) for %: 'NoneType' and 'tuple'"

  28. 28

    TypeError: unsupported operand type(s) for +=: 'float' and 'NoneType' in Python 3

  29. 29

    TypeError: unsupported operand type(s) for +: 'NoneType' and 'int' in while loop

HotTag

Archive