Posted By

maturanti19 on 05/22/19


Tagged

python random array with and work IT


Versions (?)

random generovanie poli a pod seba a naruby a scitanie


 / Published in: Python
 

scitanie poli napisanie poli pod seba generovanie random pola

  1. from random import *
  2.  
  3. def generate(n):
  4. po=[]
  5. global po
  6. #po=[] urobi z cisla zoznam, po, p, z je pole v tomto programe
  7. for i in range(n):
  8. prvok=randrange(-10,11)
  9. po=po+[prvok]
  10. print(po)
  11.  
  12. def pod_seba():
  13. global po
  14. for i in range(len(po)):
  15. print(po[i])
  16.  
  17. def p_naruby():
  18. p=[5, 10, 16, 24, 19, 34]
  19. for i in range(len(p)):
  20. print(p[i-p[0]])
  21.  
  22. def scitanie(n):
  23. z=[]
  24. global p
  25. for i in range(n):
  26. z=z+[randrange(-10,21)]
  27. print(z)
  28. s=0
  29. for i in range(n):
  30. s=s+z[i]
  31. print(s)
  32.  
  33. ##p=[5, 10, 16, 24, 19, 34]
  34. ###p=[0,1,2,3,4] - zacina pocitat od 0
  35. ##print(p)
  36. ##print(p[2])
  37. ##generate(15)
  38. ##pod_seba()
  39. p_naruby()
  40. ##scitanie(5)

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: milessmith on June 4, 2019

Thanks for sharing.I found a lot of interesting information here. A really good post, very thankful and hopeful that you will write many more posts like this one. https://akinator.ooo/ https://kodi.software/download/ https://anydesk.vip/

Posted By: milessmith on June 4, 2019

Thanks for sharing.I found a lot of interesting information here. A really good post, very thankful and hopeful that you will write many more posts like this one. https://akinator.ooo/ https://kodi.software/download/ https://anydesk.vip/

You need to login to post a comment.