Advertisement
Guest User

Untitled

a guest
Nov 13th, 2018
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. 1.
  2. n = int(input("Unesi prirodan broj: "))
  3. s = 0
  4. for i in range(n):
  5. if i % 2 == 0:
  6. s += i
  7. print("Suma je", s)
  8.  
  9. 2.
  10. n = int(input("Unesi prirodan broj: "))
  11. x = 97
  12. z = n
  13. for i in range(n):
  14. for j in range(z):
  15. print("{0:2}".format(chr(x)), end=" ")
  16. print()
  17. x += 1
  18. z -= 1
  19.  
  20. 3.
  21. from math import sqrt
  22. n = int(input("Unesi prirodan broj: "))
  23. nsq = sqrt(n)
  24. if nsq % int(nsq) == 0:
  25. print("Uneseni broj je kvadrat od prirodnog broja", int(nsq))
  26. else:
  27. print("Uneseni broj nije kvadrat prirodnog broja")
  28.  
  29. 4.
  30. from random import uniform
  31. tt = 0
  32. for i in range(10000):
  33. a = uniform(1.0, 1000.0)
  34. b = uniform(1.0, 1000.0)
  35. c = uniform(1.0, 1000.0)
  36. if a + b > c and a + c > b and b + c > a:
  37. tt += 1
  38. print("Ukupan broj trouglova je:", tt)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement