Jan-31-2023, 09:52 AM
(This post was last modified: Feb-01-2023, 12:01 AM by Larz60+.
Edit Reason: added code tags for you as Buran requests one time
)
Hi Python Community,
Greetings to you all !
After the if statement is passed through Reven and Rodd have to take two alternative indexes: one has to do multiply, and another has to do add.
like example,
Could you please help me solve this?
Greetings to you all !
After the if statement is passed through Reven and Rodd have to take two alternative indexes: one has to do multiply, and another has to do add.
like example,
Output:array has {0,1,2,3,4,5,6,7,8,9}
Reven = ((((A[0]*A[2])+A[4])*A[6])+A[8])
like
0 +2
2 *4
8 +6
14 *8
array has {0,1,2,3,4,5,6,7,8,9}
Reven = ((((A[1]*A[3])+A[5])*A[7])+A[9])
like
1 + 3
4 * 5
20 +7
27 * 8
wriiten code 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
def AddMult(A): Reven = 0 Rodd = 0 for i in range ( len (A)): if i % 2 = = 0 : Reven = Reven + A[i] else : Rodd = Rodd + A[i] E = (Reven % 2 ) O = (Rodd % 2 ) if (O > E): return "ODD" elif (E > O): return "EVEN" elif (O = = E): return "NEUTRAL" |
buran write Jan-31-2023, 10:02 AM:
Please, use proper tags when post code, traceback, output, etc.
See BBcode help for more info.
Please, use proper tags when post code, traceback, output, etc.
See BBcode help for more info.