How can I solve it TypeError unsupported operand type s for float and list

0 votes

I am trying to calculate numerical integration for each different StepSize.So I used this operator StepSize_list.append(StepSize) 

 

 
f = lambda x: 3 * x ** 2 + 2 * x

variable_list = []

initial_value = 1.0
final_value = 3.0
Actual_value = 34

StepSize_list = []

for StepSize in range(50, 250, 50):

    StepSize_list.append(StepSize)

    def Integral(L1, L2, STEP):
        delta_value = (L2 - L1) / STEP
        count = 0; Int = 0
        variable_list = []

        for k in range(STEP):
            count = count + delta_value
            variable_list.append(count)

        for k in range(len(variable_list) - 1):
            Int = Int + delta_value * ((f(L1 + variable_list[k]) + f(L1 + variable_list[k + 1])) /2)

        return Int

Calc_value = Integral(initial_value, final_value,StepSize)
Error = (abs(Actual_value - Calc_value) / Actual_value) * 100

print('Int Result is {} with {} percent Error'.format(Calc_value, Error))


and then I encountered this error:

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




Nov 17, 2020 in Python by asimsek
• 120 points
2,421 views

Hi, @Amisek,

Python doesn’t support arithmetic operation (/,*,+,-) on lists. The operators + and * are list operations.

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In Python

0 votes
1 answer

TypeError: unsupported operand type(s) for -: 'list' and 'int'

Hey, @William For me the code is working ...READ MORE

answered Mar 11, 2020 in Python by Roshni
• 10,440 points
1,558 views
+1 vote
0 answers

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

This is my part of code, why ...READ MORE

May 17, 2020 in Python by anonymous
• 220 points

edited May 18, 2020 by Gitika 544 views
0 votes
3 answers

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

& is "bitwise and" operand in Python, you ...READ MORE

answered Dec 11, 2020 in Python by Rajiv
• 8,880 points
50,850 views
0 votes
0 answers

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

Hi guys i have below code . ...READ MORE

Oct 30, 2019 in Python by sumanth
• 190 points
8,062 views
0 votes
0 answers

TypeError: unsupported operand type(s) for *: 'CommentedMap' and 'CommentedMap' Hatam bu nasıl çözebilirim ?

from ruamel import yaml from scipy import spatial import ...READ MORE

Sep 29, 2020 in Python by anonymous
• 120 points

edited Sep 29, 2020 by Gitika 124 views
0 votes
1 answer

Test Failed: unsupported operand type(s) for -: 'tuple' and 'list'

Hi, @There, Check what are you passing.. the ...READ MORE

answered Oct 5, 2020 in Python by Gitika
• 65,870 points
820 views
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 6, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 2,033 views
0 votes
0 answers
+4 votes
6 answers

Lowercase in Python

You can simply the built-in function in ...READ MORE

answered Apr 11, 2018 in Python by hemant
• 5,810 points
1,556 views