I've been working on this class assignment for my coding class for 2 days, should've taken no more than 15 minutes. Couldn't get the code to output the way expected. Your video basically helped me finally connect the dots on how to complete the assignment! Thank you!
Awesome video. This really helped me learn nested loops. For anyone wondering how to print this triangle without using nested loops, here’s one approach: i=8 for j in range(1,17,2): print(i*" "+j*"*") i=i-1 # i is the number of spaces, and j is the number of stars being printed, which goes down by 2 each row.
I was struggling with nested for loops, the range function and pattern printing until this video. I've watched several videos and this was the ah ha moment. Thanks.
Thank you for the great explanation , this really helped me intepret another project that was using different symbols. defintely gonna practise the pyramid for fun though.
Great vid! I got this in 4 tries, but my code was a little cleaner just because I used a variable ('x') for the number of 0s printed: x = 1 # number of 0s for i in range(0,7): # number of rows for j in range(0,7-i): # number of spaces over, starting with 7 but decreasing by 1 each time print(' ', end = '') print('0' * x) # number of zeros to print on each line x += 2 # increment the number of zeros by 2 to get increasing, consecutive odd numbers for each row (1,3,5,...)
@ in the pattern we left spaces then print 0.. it means after 7 spaces we have to print 0..then on the next line we have left 5 spaces then print 0.. likewise it goes on .. and because we have to print 2 more 0's on each next line thats why we multiply by 2 and decrease it by 1..
@@RecursiveTriforce How would you resolve this code to execute range values higher than 8? I am learning, and when I use your code I see that numbers 9 and above do not make perfect pyramids, so I asked myself well what should you do to fix that and make it perfect. But my problem is I barely understand your code. On top of answering this question, if you would, can you point me to some good learning websites? How did you learn this so well?
@@taylorbell6879 for x in range(size-1): print(" "*(size-x) + "0"*(2*x+1) ) For syntax I would recommend: ruclips.net/p/PLQVvvaa0QuDe8XSftW-RAxdo6OmaeL85M But this is just string formatting. Draw a pyramid with dimensions and you see... Uneven number of 0's: [ "0"*(2*x+1) ] In front of the zeros is always one less space: [ " "*(start-x) ] After the zeros: Newline [implied in print]
why does nested for loop iterates 7 times? outside for loops iterates 7 times * nested range but why nested loop should do it 7 times too? should not it loop only 1 time as an independent loop would do?
Okay, I like to try before I watch the solution. I didn't really get the isosceles triangle you got, but I did make right triangle. I just need to work on the spaces, But I don't have time right now, so heres my code so far. z,x,w,v = "*" , 1 , " ", 6 for i in range(0,4): for j in range(0,5): print(v*w+z*x) x+=1
pyramid_width = 10 for i in range(0, pyramid_width): print(" " * (pyramid_width - i), end="") n = 2 * i + 1 print("$" * n) I try this it gives same result wow coding is sweet
for i in range(0, 7): for j in range(0, 7-i): print(" ", end="") for k in range(i*2): print("0",end="") print("0") This worked for me. One thing I don't understand here, when I look at this on PythonTutor, is why in the k-index, on the first line (where i=0, and thus k=0 as 0*2=0), the program doesn't start the k loop, but instead jumps down to the print statement and then starts again at i=1. While this program accomplishes what I want, I don't understand what is going on. Since indexes start at 0, as for example in our for-loops, where the range starts at 0, allowing n to be what we want (since range goes up to n-1, if we start at 0, range will go to n), I wonder why, when i=0, k should also be 0, and then the print statement under k's loop should be printed? When following along in PythonTutor, k doesn't start until we get to the next line, with i=1 (so k's range is 1*2 = 2, so index of 0 and 1). So why does Python(?) require that i be a non-zero value, for a loop whose range is i*some-number? I just don't understand this, and any clarification from some knowing person would be amazing.
##'QUESTION HERE## for i in range(0,7): for j in range(7 - i) /// but yours starts at (0,7): print(' ', end = '') print('0') '' why is this code giving me the same output as yours? For me its logical that second loop starts at 7 so it prints 7 spaces at start of the first iteration.
I did for loop with 4, and later, I will do with 5 .The program takes all combinations for mega million and powerball 😅 .I did run this program in liberty basic and truebasic it will take more than 4 hours, and in phyton, it will take less. THIS WHY I AM LEARNING PHYTON .It was free to download others I paid.
Hello please i need help, So I have this gridded data of dimention (144,72,636). this is montthy precipitation data and I want to calculate sliding window percentiles for 10 years window for 5th 50th and 95 percentiles. who can please help me.
even if i watch this 200 times, i wont get it. The only thing i could do was for i in range(7): for j in range(7): its so confusing and idk what to do. i watched this tutorial " Python Tutorial - Python Full Course for Beginners " and repeated the nested loops part like 10 times , i still cant understand a SHIT
*1 second into the video of speaking* me: OH THANK GOD SOME CLEAR ENGLISH SPEAKING PERSON seriously. all love no offense to the other videos I seen but it was literally like listening to gibberish
I've been working on this class assignment for my coding class for 2 days, should've taken no more than 15 minutes. Couldn't get the code to output the way expected. Your video basically helped me finally connect the dots on how to complete the assignment! Thank you!
I had doubts for months about the shit for loop, I wish I watched this tutorial on my first programming day. Thank you bro
Awesome video. This really helped me learn nested loops. For anyone wondering how to print this triangle without using nested loops, here’s one approach:
i=8
for j in range(1,17,2):
print(i*" "+j*"*")
i=i-1
# i is the number of spaces, and j is the number of stars being printed, which goes down by 2 each row.
I was struggling with nested for loops, the range function and pattern printing until this video. I've watched several videos and this was the ah ha moment. Thanks.
Excellent visual presentation! Great voice. Thank you for using a large font. You are a good teacher.
excellent explanation, I learned a lot as you went thru this step by step. Thank you.
You taught us this in the best possible way
Excellent, Sir. I really liked your approach. It is unique and most logical. I can connect the dots after every steps .
I have been to so many videos for understanding loops by far u are the best one . thanks pls keep up the good work I subscribed
it was a nice, simple, and quick explanation, i understood it very quickly
great video, appreciate the step-by-step thinking approach
Thank you very much, I was able to learn this subject better thanks to your help.
Keep up the Good Work Mate! Understood the concept...Thanks!
Thank you for explaining these concepts so well.
You are my savior!!
Thank you for the great explanation , this really helped me intepret another project that was using different symbols. defintely gonna practise the pyramid for fun though.
Great vid! I got this in 4 tries, but my code was a little cleaner just because I used a variable ('x') for the number of 0s printed:
x = 1 # number of 0s
for i in range(0,7): # number of rows
for j in range(0,7-i): # number of spaces over, starting with 7 but decreasing by 1 each time
print(' ', end = '')
print('0' * x) # number of zeros to print on each line
x += 2 # increment the number of zeros by 2 to get increasing, consecutive odd numbers for each row (1,3,5,...)
iv been trying to solve this for a day. Thank you so much
for i in range(1,8):
for j in range(1,8-i):
print(" ",end="")
print("0"*(2*i-1))
Why 8-i
@ in the pattern we left spaces then print 0.. it means after 7 spaces we have to print 0..then on the next line we have left 5 spaces then print 0.. likewise it goes on .. and because we have to print 2 more 0's on each next line thats why we multiply by 2 and decrease it by 1..
Now that is a nice bit of code...thanks for sharing
Wow your teaching is amazing
Very clean and neat presentation.. Its really very helpful..
try this way:
for x in range(1,10):
print(' '*(9-x)+'*'*(x*2))
for x in range(6):
print( " "*(7-x) + "0"*(2*x+1) )
In this exact problem.
@@DeViLTh0rn why?
@@RecursiveTriforce How would you resolve this code to execute range values higher than 8? I am learning, and when I use your code I see that numbers 9 and above do not make perfect pyramids, so I asked myself well what should you do to fix that and make it perfect. But my problem is I barely understand your code. On top of answering this question, if you would, can you point me to some good learning websites? How did you learn this so well?
@@taylorbell6879
for x in range(size-1):
print(" "*(size-x) + "0"*(2*x+1) )
For syntax I would recommend:
ruclips.net/p/PLQVvvaa0QuDe8XSftW-RAxdo6OmaeL85M
But this is just string formatting. Draw a pyramid with dimensions and you see...
Uneven number of 0's:
[ "0"*(2*x+1) ]
In front of the zeros is always one less space:
[ " "*(start-x) ]
After the zeros:
Newline [implied in print]
@@RecursiveTriforce this code makes error
How did you comment the piramide all at once? Seems like a usefull hotkey.
i can't figure it out too. there is a command key for commenting blocks of code at ones. i just don't understand it.
@@FT4YOU me neither.
4:16 how do you comment it?
Will you please tell me what mathematics involved in printing pyramid. Will explain how it works?
why does nested for loop iterates 7 times? outside for loops iterates 7 times * nested range but why nested loop should do it 7 times too? should not it loop only 1 time as an independent loop would do?
Super sir your video are helpful for my online classes
Okay, I like to try before I watch the solution. I didn't really get the isosceles triangle you got, but I did make right triangle. I just need to work on the spaces, But I don't have time right now, so heres my code so far.
z,x,w,v = "*" , 1 , " ", 6
for i in range(0,4):
for j in range(0,5):
print(v*w+z*x)
x+=1
those 2 for loops at the same indentation - think its possible to do that in a list comp?
what a nice/clear way to teach. ty
but how do you get rid of that single space?
pyramid_width = 10
for i in range(0, pyramid_width):
print(" " * (pyramid_width - i), end="")
n = 2 * i + 1
print("$" * n)
I try this it gives same result wow coding is sweet
if you had a list of numbers how could you group every set of 4 numbers together? so if you had 12 numbers you would have 3 lists of 4.
Please cover the topic for regular expression in python
where are these exercises you speak of?
but how it internally implement the iteration protocol is the real magic. how does it implement it??
for i in range(0, 7):
for j in range(0, 7-i):
print(" ", end="")
for k in range(i*2):
print("0",end="")
print("0")
This worked for me. One thing I don't understand here, when I look at this on PythonTutor, is why in the k-index, on the first line (where i=0, and thus k=0 as 0*2=0), the program doesn't start the k loop, but instead jumps down to the print statement and then starts again at i=1. While this program accomplishes what I want, I don't understand what is going on. Since indexes start at 0, as for example in our for-loops, where the range starts at 0, allowing n to be what we want (since range goes up to n-1, if we start at 0, range will go to n), I wonder why, when i=0, k should also be 0, and then the print statement under k's loop should be printed? When following along in PythonTutor, k doesn't start until we get to the next line, with i=1 (so k's range is 1*2 = 2, so index of 0 and 1). So why does Python(?) require that i be a non-zero value, for a loop whose range is i*some-number? I just don't understand this, and any clarification from some knowing person would be amazing.
what was your output please? It showed me some errors
##'QUESTION HERE##
for i in range(0,7):
for j in range(7 - i) /// but yours starts at (0,7):
print(' ', end = '')
print('0')
''
why is this code giving me the same output as yours? For me its logical that second loop starts at 7 so it prints 7 spaces at start of the first iteration.
okay i got it. I forgot that the outer loop iterates only once, and the inner one iterates to the end of the range it haves. xD
t=int(input("put the number here:"))
for i in range(t):
print(" " * (t-i-1) + "*"" " * (i+1))
Can u tell me how to double the rectangle bro?
pls give a link of nested loops questions with solutions
thanks for this! loved it
Thanks! This vid helped a lot!
In my program print(" ",end="") is not running.it say end="" syntax error .please give me a suggestion to solve this problem
becaus you have 2 pythone vershion!
This was beautiful. thanks.
Sir can u write a python program calendar without built in function
You probably don't even know what a leap year is.
You can but working with time is tedious.
How to apply nested for loop for float numbers?
?
How to get rid of that last one space?
Which?
I did for loop with 4, and later, I will do with 5 .The program takes all combinations for mega million and powerball 😅 .I did run this program in liberty basic and truebasic it will take more than 4 hours, and in phyton, it will take less. THIS WHY I AM LEARNING PHYTON .It was free to download others I paid.
very clean
That was awesome 😎
Amazing! Thank you!
this my way
n = input('inter number')
n = int(n)
for i in range (n):
i = i + 1
print((n-i) * " " ,(i * 2 - 1) * " *")
why does i = 1
here i is the number of rows in the pyramid.
Perfect 👏👍🙏🏽
Thanks for the video
i=8
for j in range(-1,17,2):
print(i*" "+j*"0")
i=i-1
way more easier tbh
when u put "for j in range(-1,17,2)" its going to add 2 to -1 until it reaches 17, right???
pyramid depends on ' i '. illuminati confirmed
ركز الله يهديك😂
thank you so much..
i just dont get it
Hello please i need help, So I have this gridded data of dimention (144,72,636). this is montthy precipitation data and I want to calculate sliding window percentiles for 10 years window for 5th 50th and 95 percentiles. who can please help me.
even if i watch this 200 times, i wont get it. The only thing i could do was for i in range(7):
for j in range(7):
its so confusing and idk what to do. i watched this tutorial " Python Tutorial - Python Full Course for Beginners " and repeated the nested loops part like 10 times , i still cant understand a SHIT
same here this shit is annoying as hell
@@vaby7789 fr
I understand it but I just don't understand end="" and print("") at the end
hard to understand
thank you!
*1 second into the video of speaking*
me: OH THANK GOD SOME CLEAR ENGLISH SPEAKING PERSON
seriously. all love no offense to the other videos I seen but it was literally like listening to gibberish
This is so confusing to wrap your head around... I mean this when not following the video steps.
thank for you this
4:27
I've never used a wa-loop :)
Sir can you make your code more visible it pains my eyes watching for long time simply by adjustment of themes like that
genius
Noice
illoopminati
how to do print something then loop it forever
for i in range(6):
for j in range(0,6-i):
print(' ',end="")
for k in range(0,2*i):
print('0',end="")
print("0")
Thank u
How do I get the triangle upside down