Click here to Skip to main content
15,941,615 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Get the arithmetic mean of the elements on the even and odd positions.

What I have tried:

import random
a=input
s=0
x=0
l=random.sample((1,30),a)
for i in range(1,a+1) :
   if i %2 ==0 :
        s+=s+element
        r+=1
   else :
        x+=x+element
        t+=1
o=s/r
print o
z=x/t
print z
Posted
Updated 14-Sep-18 18:10pm

1 solution

Where did you get this code from? You have no clue about it. For example:
1. what is
a=input
?
2. what is
random.sample((1,30),a)
?
3. what is
element
?
4. Many more syntax and logical errors...
You really have to start to Learn Python[^] properly. BTW, ditch Python 2, go for Python 3.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900