Given an array of integers, determine whether each is a power of 2, where powers of 2 are [1,2,4,8,16,32,...] How do I append an array a value of 1 if it's a power of 2 or 0 otherwise.
#!/bin/python3
import math
import os
import random
import re
import sys
# The function is expected to return an INTEGER_ARRAY.
# The function accepts INTEGER_ARRAY arr as parameter.
def isPower(arr):
# Write your code here
if __name__ == '__main__':
fptr = open(os.environ['OUTPUT_PATH'], 'w')
arr_count = int(input().strip())
arr = []
for _ in range(arr_count):
arr_item = int(input().strip())
arr.append(arr_item)
result = isPower(arr)
fptr.write('\n'.join(map(str, result)))
fptr.write('\n')
fptr.close()