Python Forum
dividing by list not possible?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
dividing by list not possible?
#1
Greetings!

I was wondering why it is possible to create a new list by multiplying or adding constants to an old list, but not to create a new list through division of a float by an old list.

import numpy as np
import matplotlib.pyplot as plt

N=500;
R=0.5;

pressure_list=[16,25,40]
expectation_val_V=[445.186, 412.284, 390.5]
expectation_eta=(float(4)/3 *np.pi *R**3)/expectation_val_V

eta=np.linspace(0.5,0.70,100000)
p_red=6/(np.pi)*eta*( (12-3*(4*(1-(3*np.sqrt(2))/(np.pi)*eta)))/(4*(1-(3*np.sqrt(2))/(np.pi)*eta)) 
            +2.557696+0.1253077*(4*(1-(3*np.sqrt(2))/(np.pi)*eta)) 
            +0.1762393*(4*(1-(3*np.sqrt(2))/(np.pi)*eta))**2 
            -1.053308*(4*(1-(3*np.sqrt(2))/(np.pi)*eta))**3
            +2.818621*(4*(1-(3*np.sqrt(2))/(np.pi)*eta))**4 
            -2.921934*(4*(1-(3*np.sqrt(2))/(np.pi)*eta))**5
            +1.118413*(4*(1-(3*np.sqrt(2))/(np.pi)*eta))**6)


plt.plot(eta,p_red)
plt.show()
In this example, p_red is well defined. However, expectation_eta cannot be created. It gives the error 'TypeError: unsupported operand type(s) for /: 'float' and 'list''
Isn't this a bit contradictory from a programming point of view?

Regards!
Reply


Messages In This Thread
dividing by list not possible? - by SchroedingersLion - Oct-01-2018, 09:58 PM
RE: dividing by list not possible? - by buran - Oct-02-2018, 07:03 AM
RE: dividing by list not possible? - by ichabod801 - Oct-02-2018, 12:32 PM
RE: dividing by list not possible? - by volcano63 - Oct-02-2018, 04:43 PM
RE: dividing by list not possible? - by volcano63 - Oct-11-2018, 10:00 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
Question Dividing a single column of dataframe into multiple columns based on char length darpInd 2 2,505 Mar-14-2020, 09:19 AM
Last Post: scidam
  When dividing elements of matrix i would like the result 0 instead of inf? Koczkodan 4 3,010 Jul-22-2019, 11:40 AM
Last Post: Koczkodan
  linspace not dividing equal intervals sheel 0 2,431 Jan-16-2018, 04:28 PM
Last Post: sheel

Forum Jump:

User Panel Messages

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