Loop and the list

Batista, Facundo FBatista at uniFON.com.ar
Fri May 14 09:52:29 EDT 2004


It would be nice if you just post the trouble function and the values that
you pass to the function and makes it behave strange.

Thanks.

Facundo Batista
Desarrollo de Red
fbatista at unifon.com.ar
(54 11) 5130-4643
Cel: 15 5132 0132



#- -----Mensaje original-----
#- De: Krzysztof Szynter [mailto:dygimailNo at SPAMpoczta.fm]
#- Enviado el: Viernes 14 de Mayo de 2004 10:47 AM
#- Para: python-list at python.org
#- Asunto: Loop and the list
#- 
#- 
#- 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[i]):
#-             max = i
#-             print TY[i],max
#-             continue            
#-     return max
#- 
#- def normowanie(TY):    #normalize the TY list items
#-     for i in range(0,len(TY)-1):
#-         TY[i] = TY[i]/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.
#- 
#- -- 
#- Krzysztof Szynter         :'''.       :.   :                  *
#- Dygi GG 1027078           :...' ..... : :  : ..... . . . .    . .....
#- http://newbie.friko.pl    :   : :.... :  : : :.... :: :: :..  : :....
#- dygimail(at)poczta(dot)fm :...' :.... :   ': :.... :   : :..' : :....
#- -- 
#- http://mail.python.org/mailman/listinfo/python-list
#- 




More information about the Python-list mailing list