Powers of 11 Pattern in Python

What You’ll Learn
How to print the powers of 11 pattern in Python: 1, 11, 121, 1331, 14641. These are \(11^0\) to \(11^4\).
This is a neat pattern because (for small powers) the digits resemble Pascal’s triangle rows.
⭐ Pattern Output
For n = 5 lines, the output looks like this:
1
11
121
1331
14641Complete Python Program
Start with 1, then multiply by 11 on each step to generate the next line.
res = 1
for _ in range(5):
print(res)
res *= 11🧠 How It Works
Start with 1
res = 1 represents \(11^0\).
Print current value
Each iteration prints the current power of 11.
Multiply by 11
res *= 11 moves from \(11^k\) to \(11^{k+1}\).
Repeat for n lines
Run the loop n times to print n powers.
Powers of 11
This prints one line per iteration, so it’s linear in the number of lines.
Variation — User Input Version
Let the user choose how many lines to print, and generate each line as 11**power.
n = int(input("Enter number of lines: "))
if n < 1:
raise ValueError("n must be at least 1")
for power in range(n):
print(11 ** power)💡 Tips for Enhancement
Try These
- Print more lines and observe where carrying starts (e.g., \(11^5 = 161051\))
- Generate Pascal’s triangle directly and compare digits
- Format large values using underscores (
{value:_}) for readability - Use big integers confidently—Python handles them automatically
- Try base-10 vs base-11 representations as an extension
Avoid
- Assuming the Pascal’s triangle digit trick works for all powers (carrying breaks it)
- Accepting invalid input without handling
n < 1 - Using floating-point exponentiation (
pow(11, p)as float) for large p - Printing huge powers without thinking about output size
Key Takeaways
The lines are powers of 11: \(11^0\) to \(11^{n-1}\).
You can generate iteratively (*= 11) or using exponentiation (11**p).
For small powers, digits resemble Pascal’s triangle (before carrying).
The loop prints one value per line, so it’s O(n) lines.
❓ Frequently Asked Questions
n lines, so it’s linear in the number of lines. Computation cost increases with digits for large powers.Explore More Python Number Patterns!
Mix math ideas with loop practice to discover more interesting numeric patterns.
Binomial coefficients from Pascal’s triangle appear in \((a+b)^n\). Setting \(a=10\) and \(b=1\) gives \(11^n\), which is why this pattern is related.
7 people found this page helpful
