Python Forum
Creating Vector from a Program
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Creating Vector from a Program
#1
Hello everyone.
I am a new programmer.
I am trying to create a vector called "pressure", below is an example for the calculations that I have been trying to do.
Below is just a small piece from my code, which is the part that I am trying to solve. Also I simplified the "formula".


 
pressure = []

i = 1
    p0 = 50
    pcp0 = 20
    n = 10
    while i < n:
        p1 = p0 - 0.17 * pcp0
    for pressure in i:
        pressure.append(p1)
        i = i + 1
        p0 = p1 
The error is for pressure in i:
TypeError: 'int' object is not iterable
Reply
#2
(Oct-08-2019, 02:48 AM)ericvrocha Wrote: I am trying to create a vector called "pressure", below is an example for the calculations that I have been trying to do.

 
pressure = []

i = 1
    p0 = 50
    pcp0 = 20
    n = 10
    while i < n:
        p1 = p0 - 0.17 * pcp0
    for pressure in i:
        pressure.append(p1)
        i = i + 1
        p0 = p1 
The error is for pressure in i:
TypeError: 'int' object is not iterable

Hi!

I find your code a bit strange.

First, your indentation seems to be wrong.

Second, we learnt at high school that a vector has 1 component if the vector is on a line, like v = (v1), 2 components if the vector is on a plane, like v = (v1, v2) and 3 components if the vector is in space, like v = (v1, v2, v3). I think you are trying to add 9 elements to your vector named 'pressure', from value i = 1 (line 3) to value i = 9 (lines 6, 7 and 11).

Third, your line 9:

for pressure in i:
has no sense to me, because it is just a single value at a time.

Fourth, on your line 8:

p1 = p0 - 0.17 * pcp0
p0 is a constant (p0 = 50), pcp0 is a constant (pcp0 = 20), so p1 is also a constant (p1 = (50) - (0.17 * 20) = 50 - 3.4 = 46.6) (it's independent of 'i' values, and it's not going to change).

Fifth, p0 = p1, is after what you intend to be a loop, so it's not going to change values in the loop either.

All the best,
newbieAuggie2019

"That's been one of my mantras - focus and simplicity. Simple can be harder than complex: You have to work hard to get your thinking clean to make it simple. But it's worth it in the end because once you get there, you can move mountains."
Steve Jobs
Reply
#3
ericvrocha Wrote:I am trying to create a vector called "pressure"
Can you describe which values the vector is supposed to contain?

newbieAuggie2019 Wrote:we learnt at high school that a vector has 1 component ...
It is true but in general a vector can have as many components as one wants. Such vectors simply live in higher dimensional spaces.
Reply
#4
(Oct-08-2019, 07:20 AM)Gribouillis Wrote:
newbieAuggie2019 Wrote:we learnt at high school that a vector has 1 component ...
It is true but in general a vector can have as many components as one wants. Such vectors simply live in higher dimensional spaces.
Thank you!

Here I'm learning many things, among them, that one cannot take as eternal truths, things that you have been taught by your teachers, or even things that you have been reading in supposedly good specialistic books.

Thanks again for enlightening me!

All the best,
newbieAuggie2019

"That's been one of my mantras - focus and simplicity. Simple can be harder than complex: You have to work hard to get your thinking clean to make it simple. But it's worth it in the end because once you get there, you can move mountains."
Steve Jobs
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Question How to understand the vector/direction mason321 0 1,113 Dec-14-2021, 10:57 PM
Last Post: mason321
  How to find vector of a 3D plot mason321 0 1,017 Nov-13-2021, 05:05 PM
Last Post: mason321
  creating simplex tableau pivot program easy or difficult for a beginner in Python? alex_0 2 2,579 Mar-31-2021, 03:39 AM
Last Post: Larz60+
  3D vector class with inheritance from 2D vector class buss0140 4 3,151 Dec-20-2020, 08:44 PM
Last Post: deanhystad
  Issue with def norm in class Vector DimosG 4 2,488 Mar-26-2020, 05:03 PM
Last Post: DimosG
  creating hex dump modifying program ensoniq 3 2,639 Oct-14-2019, 08:21 AM
Last Post: Larz60+
  Problem in creating a vector termo 11 3,914 Oct-10-2019, 03:09 PM
Last Post: stullis
  How to combine two float64 column vector? dsarica 1 2,407 Apr-17-2019, 07:22 PM
Last Post: Yoriz
  Creating a Mindmap program J_Miller 3 6,395 Apr-06-2019, 05:21 PM
Last Post: ichabod801
  creating a list during program execution. hobbyprogrammer 2 2,405 Jan-26-2019, 09:06 PM
Last Post: hobbyprogrammer

Forum Jump:

User Panel Messages

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