Advertisement
SalvCai

Untitled

Feb 14th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  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 ordina (lista):
  11.  
  12. for i in range(len(lista)-1,0,-1):
  13. for j in range (i):
  14. if lista[j] > lista[j+1]:
  15. tmp = lista [j]
  16. lista [j] = lista [j+1]
  17. lista[j+1] = tmp
  18.  
  19. return(lista)
  20.  
  21. def riordina (values):
  22. ordx = []
  23. print (len(values))
  24. for element in values:
  25. if (element%2==0):
  26. ordx.append(element)
  27. values.remove(element)
  28. print (len(values))
  29. for i in range (len(values)):
  30. ordx.append(values[i])
  31. return ordx
  32.  
  33. def stampa(lista):
  34. print(" ####### = ", lista)
  35. return
  36.  
  37. def main ():
  38.  
  39. values = popola()
  40. stampa(values)
  41. values = ordina(values)
  42. stampa(values)
  43. ordx = riordina (values)
  44. stampa(ordx)
  45. print ()
  46.  
  47. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement