K
Krzysztof Szynter
Hi all
Have got a big problem. This is my code:
-----BEGIN
#stale programowe
G = 6.67E-11
Mz = 6E+24
Rz = 6.37E+6
TX = range(10,780,2)
TY = []
def skoknatezenia(ilpkt):
"Oblicza skok"
dr = ((2*Rz)-Rz)/ilpkt
return dr
def natezeniep(TX,TY,dr):
"Liczy natezenie w przedziale <Rz,2*Rz>"
cnt = 0
for i in range(0,2*Rz,dr):
TY.append((G*Mz)/((Rz+cnt)*(Rz+cnt)))
cnt = cnt + dr
return TY
def maxvalue(TY): #gets an index of the max value in the TY list
max = 0
for i in range(0,len(TY)):
if (max<TY):
max = i
print TY,max
continue
return max
def normowanie(TY): #normalize the TY list items
for i in range(0,len(TY)-1):
TY = TY/float(TY[0]) #for example '0', should be 'max'
return TY
Koniec = False
while Koniec <> True:
try:
Koniec2 = False
while Koniec2 <> True:
ilpkt = raw_input("Podaj ilosc punktow do wykreslenia 200):\t")
try:
int(ilpkt)
ilpkt = int(ilpkt)
Koniec2 = True
except:
print "Ilosc punktow musi byc liczba calkowita!\t"
continue
Koniec = True
except:
print "Nieoczekiwany blad. Sprobuj jeszcze raz."
dr = skoknatezenia(ilpkt)
TY = natezeniep(TX,TY,dr)
print TY #first main point
max = maxvalue(TY)
print "max =",max
TY = normowanie(TY) #normalize the function
print TY
-----END
I don't understand why function maxvalue returns "9". When i start a
program and check TY list in 'first main point', the max value has an index
0'. Then putting the list into the function maxvalue, gives me the index
'9'. ;--/
Where is the mistake?
ps
Apologise for the Polish text's, in the code. I'll answer for any question.
Have got a big problem. This is my code:
-----BEGIN
#stale programowe
G = 6.67E-11
Mz = 6E+24
Rz = 6.37E+6
TX = range(10,780,2)
TY = []
def skoknatezenia(ilpkt):
"Oblicza skok"
dr = ((2*Rz)-Rz)/ilpkt
return dr
def natezeniep(TX,TY,dr):
"Liczy natezenie w przedziale <Rz,2*Rz>"
cnt = 0
for i in range(0,2*Rz,dr):
TY.append((G*Mz)/((Rz+cnt)*(Rz+cnt)))
cnt = cnt + dr
return TY
def maxvalue(TY): #gets an index of the max value in the TY list
max = 0
for i in range(0,len(TY)):
if (max<TY):
max = i
print TY,max
continue
return max
def normowanie(TY): #normalize the TY list items
for i in range(0,len(TY)-1):
TY = TY/float(TY[0]) #for example '0', should be 'max'
return TY
Koniec = False
while Koniec <> True:
try:
Koniec2 = False
while Koniec2 <> True:
ilpkt = raw_input("Podaj ilosc punktow do wykreslenia 200):\t")
try:
int(ilpkt)
ilpkt = int(ilpkt)
Koniec2 = True
except:
print "Ilosc punktow musi byc liczba calkowita!\t"
continue
Koniec = True
except:
print "Nieoczekiwany blad. Sprobuj jeszcze raz."
dr = skoknatezenia(ilpkt)
TY = natezeniep(TX,TY,dr)
print TY #first main point
max = maxvalue(TY)
print "max =",max
TY = normowanie(TY) #normalize the function
print TY
-----END
I don't understand why function maxvalue returns "9". When i start a
program and check TY list in 'first main point', the max value has an index
0'. Then putting the list into the function maxvalue, gives me the index
'9'. ;--/
Where is the mistake?
ps
Apologise for the Polish text's, in the code. I'll answer for any question.