Python Program for Printing Basic Right Triangle Number Pattern
Print Basic Right Triangle Number Pattern
In this Python Program, we will be discussing about how to write a program to print Basic Right Triangle Number Pattern. In this pattern, there are n numbers of rows are present which is entered by user. We will use ‘k’ variable for printing number increasing order. With every iteration of for loop, we will increase the k variable by i. So, User have to enter a single value, that will be determine as a number of rows and columns of the pattern. With the help of “for loop”, we will print the Basic Right Triangle Number Pattern.
Step 1. Start
Step 2. Take number of rows as input from the user and stored it into num.
Step 3. Take a variable ‘k’ and initialize it as 0.
Step 4. Run a loop ‘i’ number of times to iterate through all the rows which is Starting from i=0 to num.
Step 5. Run a nested loop inside the main loop for printing spaces which is starting from j=0 to i+i.
Step 6. Print ‘k’ inside the nested loop for each row.
Step 7. Inside above Nested for loop, Increase k variable by 1.
Step 8. Move to the next line by printing a new line using print() function.
num = int(input("Enter the Number: ")) k = 1 for i in range(0, num): for j in range(0, i+1): print(k, end="") k = k+1 print() # This code is contributed by Shubhanshu Arya (Prepinsta Placement Cell Student)