{"id":22240,"date":"2021-09-23T19:10:05","date_gmt":"2021-09-23T13:40:05","guid":{"rendered":"https:\/\/python-programs.com\/?p=22240"},"modified":"2021-11-22T18:35:41","modified_gmt":"2021-11-22T13:05:41","slug":"python-program-to-print-series-1-22-333-4444-n","status":"publish","type":"post","link":"https:\/\/python-programs.com\/python-program-to-print-series-1-22-333-4444-n\/","title":{"rendered":"Python Program to Print Series 1, 22, 333, 4444…n"},"content":{"rendered":"
In the previous article, we have discussed Python Program to Print Series 6, 11, 21, 36, 56…n<\/a> Examples:<\/strong><\/p>\n Example1:<\/strong><\/p>\n Input:<\/strong><\/p>\n Output:<\/strong><\/p>\n Example2:<\/strong><\/p>\n Input:<\/strong><\/p>\n Output:<\/strong><\/p>\n Below are the ways to print the series (1,22,333,4444…N) <\/strong>for\u00a0the given number N in Python.<\/p>\n Approach:<\/strong><\/p>\n Below is the implementation:<\/strong><\/p>\n Output:<\/strong><\/p>\n Approach:<\/strong><\/p>\n Below is the implementation:<\/strong><\/p>\n Output:<\/strong><\/p>\n Practice Python Program Examples<\/a> to master coding skills and learn the fundamental concepts in the dynamic programming language Python.<\/p>\n In the previous article, we have discussed Python Program to Print Series 6, 11, 21, 36, 56…n Given a number N and the task is to print the series (1,22,333,4444…N) for\u00a0the given number N in Python. Examples: Example1: Input: Given Number = 5 Output: The above series till the given number{ 5 } is : …<\/p>\n
\nGiven a number N and the task is to print the series (1,22,333,4444…N) <\/strong>for\u00a0the given number N in Python.<\/p>\nGiven Number = 5<\/pre>\n
The above series till the given number{ 5 } is :\r\n 1 22 333 4444 55555<\/pre>\n
Given Number = 8<\/pre>\n
The above series till the given number{ 8 } is :\r\n 1 22 333 4444 55555 666666 7777777 88888888<\/pre>\n
Program to Print Series 1,22,333,4444…n in Python<\/h2>\n
\n
Method #1: Using For Loop (Static Input)<\/h3>\n
\n
# Give the number N as static input and store it in a variable.\r\ngvn_numb = 5\r\nprint(\"The above series till the given number{\", gvn_numb, \"} is :\")\r\n# Loop till the given number using the for loop.\r\nfor itr in range(gvn_numb+1):\r\n # Inside the For loop, Iterate till the above iterator value of the parent for loop\r\n # using another Nested For loop(Inner For loop).\r\n for m in range(itr):\r\n # Print the iterator value of the parent for loop separated by spaces.\r\n print(itr, end=\"\")\r\n # Print the space by using the end keyword.\r\n print(end=\" \")\r\n<\/pre>\n
The above series till the given number{ 5 } is :\r\n 1 22 333 4444 55555<\/pre>\n
Method #2: Using For loop (User Input)<\/h3>\n
\n
# Give the number N as user input using the int(input()) function and \r\n# store it in a variable.\r\ngvn_numb = int(input(\"Enter some Random Number = \"))\r\nprint(\"The above series till the given number{\", gvn_numb, \"} is :\")\r\n# Loop till the given number using the for loop.\r\nfor itr in range(gvn_numb+1):\r\n # Inside the For loop, Iterate till the above iterator value of the parent for loop\r\n # using another Nested For loop(Inner For loop).\r\n for m in range(itr):\r\n # Print the iterator value of the parent for loop separated by spaces.\r\n print(itr, end=\"\")\r\n # Print the space by using the end keyword.\r\n print(end=\" \")\r\n<\/pre>\n
Enter some Random Number = 8\r\nThe above series till the given number{ 8 } is :\r\n1 22 333 4444 55555 666666 7777777 88888888<\/pre>\n
\n