Python Pattern Programs - Floyd's Triangle | Printing Numbers in Right Triangle Shape
Вставка
- Опубліковано 19 лип 2024
- In this python pattern video tutorial you will learn how to print numbers in right triangle shape or floyd's triangle program in detail.
Floyd's triangle is the right angle triangle of natural numbers. It contains consecutive numbers starting from 1 at left corner.It is named after Robert Floyd.
Here we are using nested for loop that is for loop within the for loop and logical or operator. In this tutorial we explained how can we write floyd's triangle program in python 3 as well as python 2 in detail.
For more free tutorials on computer programming
/ amulsacademy
/ amulsacademy
Tysm ..i use every of these patterns to built my logic.. and its work..
Tq.
Instablaster.
Very good explanation! Thank you!
this is very useful! i used it for to make a multiplication table.
Thank you, Your explanation was in a detail way, please upload more and more videos.
If the input for the number of rows is >=5 &
Yes while printing number pattern we will face problems:)
Thank you for sharing info:)
We can also use format() to solve that.
You can Check out:
ua-cam.com/video/L19e53kEciI/v-deo.html
:)
Amuls Academy, yes. Thanks!
Thank U so much for the video!! U explain very well!!
Thank you 😊
from one week on wards i am following u r videos
Thank you :)
This is really very nice, thank you amulya
thankyou veryy muchh...this was the only thing i was searching for...well explained
Thank you so much.. by you only I can submit my assignment
Happy to help :)
I had this problem in a job interview and couldn't figure it out :/ Thanks for the video!
really appreciate it. its really helpful, keep it up.
Glad to hear that :)
Can you show me debugging (i:e)
Each and every line, how it will be excute.....??
Magical Voice 🤞
Thank you :)
thank you ma'am for your explanation
Welcome:)
Perfect Explanation, please do more on DSA concepts
Thank you 😊
@@AmulsAcademy can you do more videos on DSA concepts ( Python ) ?
Excellent,,, especially your voice is amazing 😍
ur way of explanation is sweet as ur voice...than kew❤
This can be done in this way too :
for n in range(0,5):
for j in range((n**2 - n + 2)//2,(n**2 + n + 2)//2):
print(j,end=" ")
print()
I think u r good at math......
Can u please tell me how you derived that math expression?
oh.. great... beautiful equation
@Mohan Prasath Thanks
@@3BoxCreation Thanks
@Vinay kumar I am actually preparing for jee. From there I know making general term.
Thnkuu....u r the best
Thank you bro .... Keep going 🤗☺️😊
I am in love with the trainer. What a knowledgeable trainer
Thank you for the video
Welcome:)
Hi.. I have a request please give me a solution.
Here instead of entering rows user will input any number and that will print in this order.. Thank you. 🙂🙂
Nice Tutorial Thanks :)
Thank you :)
Osm bro u clear all my doubts
Thank you :)
Lots of thanks for easily explain thanks 😊😊
Most welcome 😊
This code may solve the problem of the alignment of 2 digit numbers in the pattern shown in this video
n=20
for i in range(1,n+1):
for j in range(1,i+1):
print(j,end=" ")
print()
Welcome to python programming :)
Uff!!!! How adorably tell it!
Thank you :)
excellent explanation
Mam,after printing 1st row the for loop for col interrupts. so when we print row 2 so the output should get as 12 naa.
How we are getting output in row 2 as 23
We are taking separate variable to print numbers and we are incrementing that after printing value so we will get continuous numbers :)
what if the input value for n to be written without double codes will it still consider it as string or will take otherwise.
In python 3, input() takes input as string.
if you mention 3, this is the integer value right, but it will treat that as string.
:)
I fall in love of your voice😍😍😍
Thank you :)
Thanks a lot for clearly explaining about iterations and rows and columns. Just subscribed.
But I have a doubt. I coded without user input. I added my own range (1,6) for i, and then (1,i+1) for j. Everything else is same as your code.
Now, when count=1 I am getting the output starting from 2. When count=0 I'm getting the proper output starting from 1.
Can you explain why?
Hi,
This code will work properly, check your code with this,
count =1
for i in range(1,6):
for j in range(1,i+1):
print(format(count,"
thank you so muchhhhhh
Good job..thank u
welcome:)
Well explain
Good Explanation
Thank you:)
Awesome 👍
I've a loop which do a task and prints a line everytime it completes the loop and I want to print numbers too everytime what can I do ?
Thank you
Thank you 🙏🏻
You’re welcome 😊
Can you please tell me how you could print the floyd's triangle in upside down shape?
Try this:
num= int(input("enter the number of rows:"))
n = int(num*(num+1)/2)
for i in range(num,0,-1):
for j in range(i):
print(format(n,"
Can you please explain that when you use more than 2 for loops how can position my print code with respect to for loop I want to print?? I because some Time I don't understand to write my print function exactly under which for loop
You need to write the print() inside inner for loop :)
Harish Reddy
Harish Reddy
Very good tutorial. However, if we wanted to make this a pyramid instead of a right triangle. How would I go about adding in the needed space to form the pyramid?
You need to write the for loop to print space:)
num=int(input("enter the number of rows:"))
n=1
for i in range(num):
for j in range(num-i-1):
print(end=" ")
for j in range(i+1):
print(n,end=" ")
n=n+1
print()
:)
Amuls Academy this left me with a pyramid that starts at 5 and is way longer than 5 rows if my input is 5. Not only that but when it gets to double and triple digits, it is not centered correctly. What could fix this issue?
To solve that 2 digit issue,
num=int(input("enter the number of rows:"))
n=1
for i in range(num):
for j in range(num-i-1):
print(" ", end=" ")
for j in range(i+1):
if n>10:
print(" ",n,end="")
else:
print(" ",n,end=" ")
n=n+1
print()
:)
Amuls Academy as the digits continue to increase to 3 and 4, how will I make sure it all centers correctly
You can use format() for that:)
Just an example:)
print(format(num,"
Thank you Mam🙏
is the program same when we use alphabets instead of numbers ?
You are Doing "great job"
Thank you:)
Can u pls help to generate a code for two right triangles side by side?
Left right triangle_right right triangle
Can you give me the answer that in which row 2020 stays ??
Mam how to print pattern in range for ex i want from 1 to 12 then what will be changes will take place in program
I didn’t get you, give me input and output :)
very good
🌹🌹
You have cutest voice❤❤❤
Best python video
Thank you 😊
@@AmulsAcademy welcome mam/sir
Good video, but u did not explain how the loop will stop at number 10. Can you please explain that part in the reply ?
I love you saying, "that's nothing but.. :)"
Like byjus teachers..😁
Thank you mam
what if i want to make this pattern with some words ( strings )?? please help me
Did you find any solution
Pls help me how to solve this question"given an integer N as starting number and K as input write a programe reprint a number pyramid of k .
What we do ,if input will be 10 and want the same output......?
Good morning....Amul mam...
Is it possible to print this sequence ,so that every column maintains the same indentation??(especially for 2 digit numbers)
I mean like this.....
1
2 3
4 5 6
7 8 9 10
11 12 13 14 15
You can use format()
Video link:
ua-cam.com/video/L19e53kEciI/v-deo.html
:)
@@AmulsAcademy thank u mam....
Genius!))
Thank you 😊
I'm getting error in line print=(num,end=" ") 😢😢
Remove = between print and (
1
2 3
6 5 4
7 8 9 10 how this pattern takes place mam please explain
🤣😂🤞
have you got solution yet?
Hai.. Thank you very much for your explanation... But, i have a doubt.. That is when we use the version 2,how can we mention for space in output??
Verry good
Thank you :)
n=int(input("Enter the end value number:"))
k=1
for i in range(1,n+1):
for j in range(1,i):
if k
Mam, after 9, I want to start from 1 instead of 10... can u help
n = int(input("rows:"))
k=1
for i in range(1,n+1):
for j in range(1,i+1):
print(format(k,"
@@AmulsAcademy thank u so much
Hell medam,
Using 3.8.0 latest paython
I am not getting exact output
Any changes in paython 3.5 and 3.8
I think No :)Give me the program i will check :)
Where you're from akka,exclent explenation.
Show me this program using concatenation property...
I tried your program with number of rows as 6 and 10 but it did not give me the exact output
Give me the program,I will check :)
Thanks mam
Pleasure :)
Hello Ma'am, How can i write code for this que
Que. Following program copies the contents of source file to a destination file.
More precisely, the code is making copy of the source file problem-1.py
# Modify the following program to copy only the code elements and skip
all the comments. Comments in python start with character '#'
can anyone tell how to reverse this triangle
Can you say how to draw the flowchart for this.
I will try 😊
Can you please explain how to get single digit and double digit in a single line?
You can format the output using format function 😊
@@AmulsAcademy yup I understood after watching the NEXT video Thankyou
Why we are taking range from 1 why not from 0 and why are taking n+1 and not n wat is the difference
Is there a way to find the sum of the numbers in the very last row of the triangle?
if you used a list to create the triangle you could cut the list at a certain point then find the sum of the numbers after that in the list
@@soph4582 thank you...but how can you do that?
how to print lower triangle matrix in python 3
Number pattern or star pattern?
Give me the pattern:)
Same code with two input please explain
Thq
Welcome :)
Very Well Explained you earned a Sub. Thanks a lot Dear
can u help me in coding the same in reverse order like shown below
10
9 8
7 6 5
4 3 2 1
I will try to upload it soon 😊
How to print alphabet in triangular shape
mam how can i contact u
You can ask your queries here, or in our fb page :)
And you are from Benglore
Ma'am i'm getting as 1
1
22
333
4444
55555 etc same code i typed
you are printing i value {or row value } that's why you are getting this output :)
You need to take another variable and store value 1 in that and you need to print that variable in the print()
:)
I Love You
write a program using number as limit instead of number of rows...
I entered correct
But output is syntax error
Super voice
Thank you 😊
@@AmulsAcademy and also wonderful explanation which is essential for beginners 🥳
😊
2 triangular pattern code example
hi
can u make a program in python which output is
1
2 3
3 4 5
6 7 8 9
9 10 11 12
Rhombus pattern?
Mam how can i write this code,
1
2 3
3 4 5
4 5 6 7
plz suggest me code
n = int(input("enter the number of rows:"))
num =1
for i in range(n):
for j in range(i+1):
print(num,end=" ")
num=num+1
num =num-i
print()
:)
s=int (1)
for r in range (0,10):
for c in range (0,r+1):
if s>10:
print ((s),(""),end='')
else:
print ((s),(" "),end='')
s=s+1
print ()
Both the replies are not working with 3.5.1 try below one:
n = int(input("Enter the number of rows:"))
for i in range(1, n + 1):
for j in range(1, i + 1):
print(i,end=" ")
i = i + 1
print()
I did not get it..plz make it simple
1
3 2
6 5 4
10 9 8 7 how to do it..?
have you got solution?
code:
start = 1
stop = 2
currentNumber = stop
for row in range(2, 6):
for col in range(start, stop):
currentNumber -= 1
print(currentNumber, end=' ')
print('
')
start = stop
stop += row
currentNumber = stop
N= yan
How to code this?
1 2 3
4 5
6
n = int(input("rows:"))
k=1
for i in range(n,0,-1):
for j in range(n-i,0,-1):
print(format(" ","
Thank you so much! 😭
Enter Multiplier: 3
1 2 3
2 4 6
3 6 9
Why is my math teacher making me locate 9999 in the triangle, what the hell ????