Advertisement
Guest User

vjezba5

a guest
Nov 13th, 2018
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.60 KB | None | 0 0
  1. #1.)
  2. from random import randint
  3. y=0
  4. while (y<10):
  5.     broj=randint(1,1001)
  6.     if broj>100 and broj<500:
  7.         y+=1
  8.         print (broj)
  9.  
  10. #2.)
  11. while True:
  12.     x=int(input("unesite x:"))
  13.     y=int(input("unesite y:"))
  14.     if x>0 and y>0:
  15.         if x>y:
  16.             for i in range (y+1,x):
  17.                 print (i)
  18.         if y>x:
  19.             for i in range (x+1,y):
  20.                 print (i)
  21.     else:
  22.         print("greška")
  23.         break
  24.  
  25. #3.)
  26. broj=int(input("unesite broj:"))
  27. x=0
  28. brojac=0
  29. while (x<32):
  30.     x+=1
  31.     if broj&1==1:
  32.         brojac+=1
  33.     broj=broj>>1
  34. print (brojac)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement