Advertisement
Programmin-in-Python

Swapping the 6th bit in a Decimal Number

Dec 26th, 2020
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.19 KB | None | 0 0
  1. def bin_check(n): # n ==> Any Decimal Number
  2.     L1 = list(bin(n))
  3.     str1 = ''
  4.  
  5.     if L1[-6] == '0':
  6.         L1[-6] = '1'
  7.  
  8.     for i in L1:
  9.         str1 += i
  10.  
  11.     return str1
  12.  
  13. val = bin_check(100)
  14. print(val)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement