daily pastebin goal
31%
SHARE
TWEET

Untitled

SalvCai Feb 14th, 2018 69 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def popola ():
  2.     values = []
  3.     print (" inserisci valore ")
  4.     valore = input("")
  5.     while valore.upper() != "Q" :
  6.         values.append(eval(valore))
  7.         valore = input("")
  8.     return values
  9.  
  10. def scambia (values, i,j):
  11.     temp = values[i]
  12.     values[i] = values[j]
  13.     values[j] = temp
  14.  
  15.  
  16. def ordina (lista):
  17.    
  18.     for i in range(len(lista)-1,0,-1):
  19.         for j in range (i):
  20.             if lista[j] > lista[j+1]:
  21.                 tmp = lista [j]
  22.                 lista [j] = lista [j+1]
  23.                 lista[j+1] = tmp
  24.            
  25.     return(lista)
  26.  
  27.    
  28. def riordina (values):
  29.     i = 0
  30.     while i<len(values)-1:
  31.         if values[i]%2 != 0:
  32.             scambia(values,i,i+1)
  33.             stampa(values)
  34.         i =i+1
  35.     return values
  36.  
  37.            
  38. def stampa(lista):
  39.     print(" #######   = ", lista)
  40.     return
  41.  
  42. def main ():
  43.    
  44.     values = popola()
  45.     stampa(values)
  46.     ordx = riordina (values)
  47.     stampa(ordx)
  48.     print ()
  49.  
  50. main()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top