Dedzbn

Odd_bit

Nov 24th, 2020 (edited)
463
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from random import randrange
  2.  
  3. num_tmp = randrange(256)
  4. bin = f'{num_tmp:08b}'
  5. bin_list = []
  6. if bin[-1] == str(0):
  7.     for x in bin:
  8.         bin_list.append(x)
  9.     bin_list.pop()
  10.     bin_list.append('1')
  11.     print(f'Было число {num_tmp}, стало {int("".join(str(x) for x in bin_list),2)}')
  12. else:
  13.     print(f'Число {num_tmp} имеет нечетный последний бит')    
RAW Paste Data