Array with elements in specific order

Can anyone help with this?

I have an array called A whose first element a11 is from the list1, the elements a31, a51, a71, a91 are also from the list1. But the elements a21, a41, a61, a81 and a101 are from a different list, the list2. I don’t know how to form the array since the elements are from different lists and in different orders.

The form of the array is:

A=[a11,
a21,
a31,
a41,
a51,
a61,
a71,
a81,
a91,
a101]

And the lists are

List1=[a11, a31, a51, a71, a91]

List2=[a21, a41, a61, a81, a101]

Is this homework?

Show us your attempt, and we can help from there.

it acually is an assignment not really “homework” and i didnt post my “effort” cause all the wording is in a foreign language and it would complicate things. all the results are correct, just in the wrong order. im posting the order i want to achieve in the screenshot below. I hope you can help.

Screenshot 2022-11-15 134424


c = 152.34

omega=0

phi=0

kappa=0

import math

r11= math.cos(phi)*math.cos(kappa)

r12= math.sin(omega)*math.sin(phi)*math.cos(kappa) + math.cos(omega)*math.sin(kappa)

r13= -math.cos(omega)*math.sin(phi)*math.cos(kappa)+math.sin(omega)*math.sin(kappa)

r21=-math.cos(phi)*math.sin(kappa)

r22=-math.sin(omega)*math.sin(phi)*math.sin(kappa) + math.cos(omega)*math.cos(kappa)

r23=math.cos(omega)*math.sin(phi)*math.sin(kappa) + math.sin(omega)*math.cos(kappa)

r31=math.sin(phi)

r32=-math.sin(omega)*math.cos(phi)

r33= math.cos(omega)*math.cos(phi)

Xo= (6050.75+6777.80+6450.20+6102.55+6653.40)/5

Yo= (12424.50+12450.45+12050.10+11407.65+11475.80)/5

Zo=944.343

X= [6050.75, 6777.80, 6450.20, 6102.55,6653.40]

Y= [12424.50,12450.45,12050.10,11407.65,11475.80]

Z= [201.70,257.6,169.2,181.3,205.8]

A=

B=

C=

D=

E=

for i in range(5):

A1=r11*(X[i]-Xo) +r12*(Y[i]-Yo) +r13*(Z[i]-Zo)

A.append(A1)

A2=r21*(X[i]-Xo) +r22*(Y[i]-Yo) +r23*(Z[i]-Zo)

B.append(A2)

P=r31*(X[i]-Xo)+r32*(Y[i]-Yo)+r33*(Z[i]-Zo)

C.append(P)

x=-c*(A1/P)

D.append(x)

y=-c*(A2/P)

E.append(y)

print("Α1 ",A)

print(“Α2 :”,B)

print(“Π:”,C)

print("x ",D)

print(" y ",E)

F=

for i in range(5):

a1=(c/C[i]**2)*(-A[i]*r31+C[i]*r11)

F.append(a1)

G=

for i in range(5):

a2=(c/C[i]**2)*(-A[i]*r32+C[i]*r12)

G.append(abs(a2))

H=

for i in range(5):

a3=(c/C[i]**2)*(-A[i]*r33+C[i]*r13)

H.append(a3)

I=

for i in range(5):

a4=(-c/C[i]2)(C[i](-r13(Y[i]-Yo)+r12(Z[i]-Zo))-A[i](-r33(Y[i]-Yo)+r32*(Z[i]-Zo)))/636620

I.append(a4)

f11=-math.sin(phi)*math.cos(kappa)

f12=math.sin(omega)*math.cos(phi)*math.cos(kappa)

f13=-math.cos(omega)*math.cos(phi)*math.cos(kappa)

f21=math.sin(phi)*math.sin(kappa)

f22=-math.sin(omega)*math.cos(phi)*math.sin(kappa)

f23=math.cos(omega)*math.cos(phi)*math.sin(kappa)

f31=math.cos(phi)

f32=math.sin(omega)*math.sin(phi)

f33=-math.cos(omega)*math.sin(omega)

J=

for i in range(5):

a5=(-c/C[i]2)(C[i](f11(X[i]-Xo)+f12(Y[i]-Yo)+f13*(Z[i]-Zo))-A[i](f31(X[i]-Xo)+f32*(Y[i]-Yo)+f33*(Z[i]-Zo)))/636620

J.append(a5)

K=

for i in range(5):

a6=((-c/C[i])(r21(X[i]-Xo)+r22*(Y[i]-Yo)+r23*(Z[i]-Zo)))/636620

K.append(a6)

L=

for i in range(5):

b1=(c/C[i]**2)*(-B[i]*r31+C[i]*r21)

L.append(b1)

M=

for i in range(5):

b2=(c/C[i]**2)*(-B[i]*r32+C[i]*r22)

M.append(b2)

N=

for i in range(5):

b3=(c/C[i]**2)*(-B[i]*r33+C[i]*r23)

N.append(b3)

O=

for i in range(5):

b4=(-c/C[i]2)(C[i](-r23(Y[i]-Yo)+r22(Z[i]-Zo))-B[i](-r33(Y[i]-Yo)+r32*(Z[i]-Zo)))/636620

O.append(b4)

P=

for i in range(5):

b5=(-c/C[i]2)(C[i](f21(X[i]-Xo)+f22(Y[i]-Yo)+f23*(Z[i]-Zo))-B[i](f31(X[i]-Xo)+f32*(Y[i]-Yo)+f33*(Z[i]-Zo)))/636620

P.append(b5)

Q=

for i in range(5):

b6=((-c/C[i])(-r11(X[i]-Xo)-r12*(Y[i]-Yo)-r13*(Z[i]-Zo)))/636620

Q.append(b6)

print(F)

print(G)

print(H)

print(I)

print(J)

print(K)

print(L)

print(M)

print(N)

print(O)

print(P)

print(Q)

import numpy as np

xa=[-73.206, 65.578, -2.616,-70.080, 34.277]

xa = np.array(xa)

xa

ya=[80.153, 94.446, 10.861,-106.349,-103.873]

dl1=xa[0]-D[0]

dl2=ya[0]-E[0]

dl3=xa[1]-D[1]

dl4=ya[1]-E[1]

dl5=xa[2]-D[2]

dl6=ya[2]-E[2]

dl7=xa[3]-D[3]

dl8=ya[3]-E[3]

dl9=xa[4]-D[4]

dl10=ya[4]-E[4]

dl=[dl1,dl2,dl3,dl4,dl5,dl6,dl7,dl8,dl9,dl10]

print(" δλ :",dl)

import array

Ai=[F,G,H,I,J,K,L,M,N,O,P,Q]

np.set_printoptions(suppress=True)

array6 = np.array(Ai)

array6=np.reshape(Ai,(10,6))

print(“A=”,arrayFromAi)

Please format your code properly. See the Quick Start topic for instructions on how to do so.

From your first post, I got the impression that you want to interlace two 1D arrays into another 1D array. But now it looks like you want a 2D array? How do the two lists you mention relate to the screenshot you posted?

Maybe it is, maybe it is not useful (are the lists equal size etc):

>>> a = [1, 3, 5, 7, 9]
>>> b = [2, 4, 6, 8, 10]
>>> [item for pair in zip(a, b) for item in pair]
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
1 Like

Why don’t people format their code properly? I have to pass on many questions because code is not formatted properly.

probably because we are beginners. you can pass on this question too

I am not mocking but I think the onboarding process is pretty clear and gives a good introduction to the forum. I think you can even take a tutorial from the discobot to speed up the process. I really want to see if we can do something to help the new comers.

The thing is, to the average newbie who posts without formatting, they think “Jeez, get off my back, old man! It’s only my first post, give me a break” and for them it is the first time, but for us it is badly formatted poor quality post number 256 and that’s just this week. For us it is a continual drain that makes it harder and harder to stay motivated to answer beginner questions.

“I’m a beginner” is not much of an excuse. Being a beginner just means that you don’t know much about programming in Python. But we’re not asking why posters aren’t Python experts. We’re asking why they do so poorly at asking their questions, starting with formatting their code.

We can’t fix this unless we know why it happens.

  • Do people spend any time reading other posts before asking their own questions?
  • If not, why don’t they?
  • Do people not Preview their post before posting?
  • Do people not wonder what the buttons on the fancy editor tool bar do?

This is supposed to be the most tech-savvy generation ever. Kids who were given their first tablet at three and are considered deprived if they don’t have a smart phone by twelve. People who learn programming in primary school. But you wouldn’t know it by the posting skills displayed.

What can we do to help?

Maybe Discourse can require people to go through an on-boarding process before they can post their first question. Maybe new accounts cannot post until they have clicked the Preview link.

I would hate hate hate that if I was a beginner. But maybe that’s the lesser evil.

Honestly I don’t have much hope that either of those will help. I think we’re doomed. When you lower the bar to entry so anyone can post, the down side is that anyone can post.

On the other hand:

  • Is some of the problem the Discourse software itself? I often receive posts in my inbox which are formatted perfectly in email, but mangled on the website.

Maybe the real problem here is that Discourse shouldn’t mangle people’s indentation regardless of whether or not the text is formatted at code.

Even for English prose, structure and indentation can be part of the text, and I hate the fashion among text widgets to mangle whitespace. But good luck at getting the programmers to acknowlege that. It’s A Feature™.

1 Like

wow. Thank God i found what i was looking for on my own

Yeah, well if you keep sneering at the people who volunteer their time and effort for free (instead of charging commercial rates that can easily reach $200 an hour for Python experts), you better hope that you find answers to any future questions on your own too.

We’re not answering questions here because we have to. If people are too obnoxious, annoying or difficult, we’ll stop.

1 Like

Then stop it’s fine, I found what I was looking for and there is really no need to keep commenting on here anymore. If my code isn’t written properly then skip my question. No need to keep telling me off you’re just wasting your time