- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to generate pyramid of numbers using Python?
There are multiple variations of generating pyramids using numbers in Python. Let's look at the 2 simplest forms
Example
for i in range(5): for j in range(i + 1): print(j + 1, end="") print("")
Output
This will give the output
1 12 123 1234 12345
Example
You can also print numbers continuously using
start = 1 for i in range(5): for j in range(i + 1): print(start, end=" ") start += 1 print("")
Output
This will give the output
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Example
You can also print these numbers in reverse using
start = 15 for i in range(5): for j in range(i + 1): print(start, end=" ") start -= 1 print("")
Output
This will give the output
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1
- Related Articles
- How to generate prime numbers using Python?
- How to generate armstrong numbers in Python?
- How does Python generate random numbers?
- How to generate XML using Python?
- How to use Python Numpy to generate Random Numbers?
- How to generate non-repeating random numbers in Python?
- Generate Secure Random Numbers for Managing Secrets using Python
- How to generate a string of bits using Python?
- How to generate prime twins using Python?
- How to generate JSON output using Python?
- How to generate statistical graphs using Python?
- How to generate the first 100 Odd Numbers using C#?
- How to generate the first 100 even Numbers using C#?
- How to generate prime numbers using lambda expression in Java?
- Python module to Generate secure random numbers

Advertisements