Part of the series

Several example codes

~1 min read • Updated Oct 6, 2025

Program Overview

This Python program generates two lists of powers of 2:
- The first column shows increasing powers: [2⁰, 2¹, 2², ..., 2⁵]
- The second column shows decreasing powers: [2⁶, 2⁴, 2³, ..., 2⁰]
The program then prints both columns side by side in a formatted table.


Python Code:


# Generate powers of 2
left_column = [2 ** i for i in range(6)]
right_column = [2 ** i for i in reversed(range(6))]

# Print table
for a, b in zip(left_column, right_column):
    print(f"{a:<4} {b}")

Sample Output:


1    64  
2    16  
4     8  
8     4  
16    2  
32    1

Step-by-Step Explanation:

- The program creates two lists using list comprehensions
- left_column increases from 2⁰ to 2⁵
- right_column decreases from 2⁵ to 2⁰
- The zip() function pairs each value
- {a:<4} ensures left alignment for clean formatting


Written & researched by Dr. Shahin Siami