Posted By

maturanti19 on 05/22/19


Tagged

random array a Pole uzivatel ktore zada spriemerovany sucet najdenie cisla


Versions (?)

random array random pole spriemerovany sucet a najdenie cisla ktore zada uzivatel


 / Published in: Python
 

sucet cisiel spriemerovany random cisla hladaj cislo ktore zadal uzivatel

  1. from random import *
  2.  
  3. def randomcisla(n):
  4. global z
  5. z=[]
  6. for i in range(n):
  7. z=z+[randrange(0,11)]
  8. print(z)
  9. randomcisla(8)
  10.  
  11. def spriemerovany_sucet():
  12. global m
  13. m=0
  14. for i in range(len(z)):
  15. m=m+z[i]
  16. print('Sucet tychto cisel je: '+ str(m))
  17. global priemer
  18. priemer = m/len(z)
  19. print('Priemer tychto cisel je: ' + str(priemer))
  20. mensie=[]
  21. for i in range(len(z)):
  22. if priemer > z[i]:
  23. print(z[i])
  24. spriemerovany_sucet()
  25.  
  26.  
  27. def hladaj_cislo(x):
  28. randomcisla(20)
  29. pozicie=[]
  30. for i in range(len(z)):
  31. if x==z[i]:
  32. pozicie=pozicie+[i+1]
  33. if pozicie==[]:
  34. print('Nasiel som!')
  35. else:
  36. print('Nasiel som! Su na poziciach: ')
  37. print(pozicie)
  38.  
  39.  
  40. x=int(input('Zadaj cislo ake mam hladat: '))
  41. hladaj_cislo(x)

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: iosman on May 26, 2019

Im in love with your content and also gain some knowledge from your blog.

Best Quiet Air Compressors

You need to login to post a comment.