Python Program to print the pattern of numbers 1 12 123|Print the following number pattern using python|Python program to print pyramid pattern |Number pattern programs in python
Introduction
For Loop
The range() function returns a sequence of numbers, starting from 0 by default, and increments by 1 (by default), and ends at a number specified by the user.
User can specify the Starting,end and the incrementation difference.
While Loop:
- how to print patterns in python using for loop
- how to print number Pyramid patterns in python using while loop And for Loop.
Now let's ,move towards our main program
Source Code(Using "For " loop):-
n=int(input("enter number of rows needed:"))
for i in range(1,n+1):
for j in range(1, i+1):
print(j, end="")print()
#Code ends
Output:-(click to view clear image)
Executed on Pydroid3 |
Source Code(Using "While " loop):-
n = "1"
specifiednum = 1
while n != "123456":
print(n, end="")
specifiednum += 1
n += str(specifiednum)
print()
Output :-
Executed on IDLE(Python 3.9 64 bit) |