{"id":22609,"date":"2021-09-27T08:33:51","date_gmt":"2021-09-27T03:03:51","guid":{"rendered":"https:\/\/python-programs.com\/?p=22609"},"modified":"2021-11-22T18:35:39","modified_gmt":"2021-11-22T13:05:39","slug":"python-program-to-print-series-10-5-60-15-110-n","status":"publish","type":"post","link":"https:\/\/python-programs.com\/python-program-to-print-series-10-5-60-15-110-n\/","title":{"rendered":"Python Program to Print Series 10, 5, 60, 15, 110 …N"},"content":{"rendered":"
In the previous article, we have discussed Python Program to Print Series -1 4 -7 10 -13 16 -19…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 ( 10, 5, 60, 15, 110 …N)<\/strong> till the 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 Find the best practical and ready-to-use Python Programming Examples<\/a> that you can simply run on a variety of platforms and never stop learning.<\/p>\n In the previous article, we have discussed Python Program to Print Series -1 4 -7 10 -13 16 -19…n Given a number N and the task is to print the series ( 10, 5, 60, 15, 110 …N) till the given number N in Python. Examples: Example1: Input: Given Number (Limit) = 14 Output: The …<\/p>\n
\nGiven a number N and the task is to print the series ( 10, 5, 60, 15, 110 …N)<\/strong> till the given number N in Python.<\/p>\nGiven Number (Limit) = 14<\/pre>\n
The above series till the given number{ 14 } is :\r\n10 5 60 15 110 25 160 35 210 45 260 55 310 65<\/pre>\n
Given Number (Limit) = 9<\/pre>\n
The above series till the given number{ 9 } is :\r\n10 5 60 15 110 25 160 35 210<\/pre>\n
Program to Print Series 10, 5, 60, 15, 110 …N in Python<\/h2>\n
\n
Method #1: Using While Loop (Static Input)<\/h3>\n
\n
# Give the number N(limit) as static input and store it in a variable.\r\ngvn_numb = 14\r\n# Take a variable to say itr and initialize its value to 1.\r\nitr = 1\r\n# Take another variable say p and initialize its value to 10.\r\np = 10\r\n# Take another variable say q and initialize its value to 5.\r\nq = 5\r\nprint(\"The above series till the given number{\", gvn_numb, \"} is :\")\r\n# Loop until the above-declared variable itr value is less than or equal to the\r\n# given number using the while loop.\r\nwhile(itr <= gvn_numb):\r\n # Inside the loop, check if the above variable itr value is even or not using the\r\n # if conditional statement.\r\n if(itr % 2 == 0):\r\n # If it is true, then print the value of q\u00a0separated by spaces.\r\n print(q, end=\" \")\r\n # Increment the above q value by 10 and store it in the same variable.\r\n q += 10\r\n else:\r\n # Else,\u00a0print the value of p\u00a0separated by spaces.\r\n print(p, end=\" \")\r\n # Increment the above p value by 50 and store it in the same variable.\r\n p += 50\r\n # Increment the above itr value by 1.\r\n itr += 1\r\n<\/pre>\n
The above series till the given number{ 14 } is :\r\n10 5 60 15 110 25 160 35 210 45 260 55 310 65<\/pre>\n
Method #2: Using While loop (User Input)<\/h3>\n
\n
# Give the number N (Limit) 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\n# Take a variable to say itr and initialize its value to 1.\r\nitr = 1\r\n# Take another variable say p and initialize its value to 10.\r\np = 10\r\n# Take another variable say q and initialize its value to 5.\r\nq = 5\r\nprint(\"The above series till the given number{\", gvn_numb, \"} is :\")\r\n# Loop until the above-declared variable itr value is less than or equal to the\r\n# given number using the while loop.\r\nwhile(itr <= gvn_numb):\r\n # Inside the loop, check if the above variable itr value is even or not using the\r\n # if conditional statement.\r\n if(itr % 2 == 0):\r\n # If it is true, then print the value of q\u00a0separated by spaces.\r\n print(q, end=\" \")\r\n # Increment the above q value by 10 and store it in the same variable.\r\n q += 10\r\n else:\r\n # Else,\u00a0print the value of p\u00a0separated by spaces.\r\n print(p, end=\" \")\r\n # Increment the above p value by 50 and store it in the same variable.\r\n p += 50\r\n # Increment the above itr value by 1.\r\n itr += 1\r\n<\/pre>\n
Enter some Random Number = 9\r\nThe above series till the given number{ 9 } is :\r\n10 5 60 15 110 25 160 35 210<\/pre>\n
\n