<jupyter_start><jupyter_text>Flipping bits![image](https://user-images.githubusercontent.com/50367487/86794963-0b9b7e80-c0a8-11ea-823d-86cf3eb44fb7.png)<jupyter_code>#!/bin/python3

import math
import os
import random
import re
import sys

# Complete the flippingBits function below.
def flippingBits(n):
    bin_n = format(n, 'b')

    full_bin_n = (32 - len(bin_n)) * "1" + "".join("0" if i == "1" else "1" for i in bin_n)

    return int(full_bin_n, 2)

if __name__ == '__main__':
    fptr = open(os.environ['OUTPUT_PATH'], 'w')

    q = int(input())

    for q_itr in range(q):
        n = int(input())

        result = flippingBits(n)

        fptr.write(str(result) + '\n')

    fptr.close()<jupyter_output><empty_output>
StarcoderdataJupyterStructuredCleanDedup