Back Number Pattern | Part 1 | Python Pattern Programs

20-30
Created By: Amulya's Academy
Published At: 2020-12-21
Search Query: Python Numbers
Tags: python python video tutorials python programming tutorials python pattern printing python pattern programs python patterns python pattern tutorial python design patterns printing star pattern triangle shape pyramid shape number pattern number
In this Python Pattern Printing Programs video tutorial you will learn how to print numbers in different shape in detail.

To print the pattern i will use nested for loops.
In this program pattern contains two for loops: the first loop is responsible for rows and the second for loop is responsible for columns.

For more free tutorials on computer programming
http://www.facebook.com/AmulsAcademy
twitter.com/AmulsAcademy
logo Ask VidTutorAssistant
Comment
or
Question
Your name
Comments with generated responses
@mathlab9210
2021-05-19

how to do
1
1 3
1 3 5
1 3 5 7
1 3 5 7 9

@AmulsAcademy

n=int(input())
k=2*n
for i in range(1,k+1,2):
for j in range(1,i+1,2):
print(j,end="")
print()

VidTutorAssistant (GPT-4)

Hello @mathlab9210, thanks for reaching out with your question! To generate the pattern you shared, it's not much different from what we've done in the tutorial. You need to use a nested loop structure. Here is how you can modify that:

```python
n = int(input("Enter the number of rows: "))
for i in range(n):
odd_num = 1
for j in range(i + 1):
print(odd_num, end = " ")
odd_num += 2 # increment to get the next odd number
print() # go to next line after printing each row
```
In this script, `i` goes up to `n-1` because Python starts from 0. The second loop prints the odd numbers starting from 1 and incrementing by 2 each time. After finishing each row, the print function without any parameter sends the cursor to the next line. Let me know if you would like me to clarify further. Happy coding!


@akhileshkumaryadav1657
2021-01-20

hi....i am a new learner
how index provided opposite. range (i,-1,-1). i did not understand. please make me understand

@AmulsAcademy

Syntax of range function is :
range(start,end,step)
here start is i {lets take i=5}
end is -1
and step is -1

first output from range(i,-1,-1) function is 5 {because i took i value as 5}
then it will see step and it will add that to start value, so here start is 5 and step -1
5-1 = 4
so second output is 4
next again for next value add step to 4
4-1 = 3
so next output is 3

So that's why we will get 5 4 3 2 1 0 {we will not get -1 because end value is exclusive}

VidTutorAssistant (GPT-4)

Hello @akhileshkumaryadav1657, welcome to the world of Python programming! I understand that "range(i, -1, -1)" can seem complicated at first. Here's a clear explanation:

In Python, the "range()" function generates a sequence of numbers starting from the start value, stops before a stop value, and increments the sequence by the step value.

So when I write 'range(i, -1, -1)', I am asking the function to start from 'i', go till '-1' (it means keep going till you reach the start of the sequence as β€˜-1’ in python indexing refers to the last index), and step forward by '-1'. In other words, we are decreasing the index value by 1 each time, which gives us the opposite or reverse order.

So if your 'i' was 4, your loop would run for values of i as 4, 3, 2, 1, 0. This helps us achieve the reversed order in our pattern.

I hope this is clear now. Don't worry, as you continue practicing, these concepts will become more familiar. Keep learning and share if you have any more queries. Happy coding!


@MRCRAZY-wm4ln
2021-02-02

fall in love with coding with you mam, thanks for providing us this quality of education....love you mam

@AmulsAcademy

Glad to hear that :)

VidTutorAssistant (GPT-4)

Hello @MRCRAZY-wm4ln! Thanks for your lovely comment. I'm so glad to hear that my tutorials are helping you fall in love with coding. That's my main goal! Remember, keep tinkering around with the patterns and don't be afraid to get creative with the loops. Always happy to keep providing quality education. Keep learning and coding. Your comments and support mean a lot to me!


@wolfpack9873
2021-01-22

U teach better than my cs teacher!πŸ˜‰
Sorry my cs ma'am!
But genuinely appreciate your teaching....just luv ur teaching pls don't stop❀️

I don't have to even read my book after this thanks a ton!😁 You Saviour!

@AmulsAcademy

Thank you so much :)

VidTutorAssistant (GPT-4)

Thank you very much @wolfpack9873! You've made our day with your kind words. It's always great to hear that our tutorials are making a difference out there! Stay tuned for more Python content and happy learning! Don't hesitate to ask if you have any more programming queries, we're here to help. πŸš€πŸ‘


@rashid_iiitd
2021-06-23

Since I found this channel I fell in love with pattern printing programs.
Itna aacha kaise padhate ho ma'am

@AmulsAcademy

Thank you 😊❀️

VidTutorAssistant (GPT-4)

Thank you so much, @rashid_iiitd! I'm glad to know that you're enjoying the pattern printing programs tutorials. Your interest and appreciation motivate me to discuss these topics in a way that makes it informative and captivating for everyone. Remember, practice makes one perfect, so keep coding! Don't forget to try altering the shapes on your own, and feel free to share your unique patterns with us! I'll be uploading more videos, so stay tuned. Happy Learning!