{"id":22604,"date":"2021-09-27T08:33:40","date_gmt":"2021-09-27T03:03:40","guid":{"rendered":"https:\/\/python-programs.com\/?p=22604"},"modified":"2021-11-22T18:35:40","modified_gmt":"2021-11-22T13:05:40","slug":"python-program-to-print-cube-number-series-1-8-27-64-n","status":"publish","type":"post","link":"https:\/\/python-programs.com\/python-program-to-print-cube-number-series-1-8-27-64-n\/","title":{"rendered":"Python Program To Print Cube Number Series 1 8 27 64…N"},"content":{"rendered":"
In the previous article, we have discussed Python Program to Print Series 6, 9, 14, 21, 30, 41, 54 … N<\/a> Cube number:<\/strong><\/p>\n A cube number is a number that has been multiplied by itself three times. This is also known as ‘a number cubed.’ Cubed is represented by the symbol \u00b3.<\/p>\n For example :<\/p>\n The cube number of 3= 3\u00b3 =3*3*3 = 27.<\/p>\n 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 cube number series (1 8 27 64…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 The best way to learn Python for Beginners is to practice as much as they can taking help of the Sample Python Programs For Beginners<\/a>. Using them you can develop code on your own and master coding skills.<\/p>\n <\/p>\n","protected":false},"excerpt":{"rendered":" In the previous article, we have discussed Python Program to Print Series 6, 9, 14, 21, 30, 41, 54 … N Given a number N and the task is to print the cube number series (1 8 27 64…N) till the given number N in Python. Cube number: A cube number is a number that …<\/p>\n
\nGiven a number N and the task is to print the cube number series (1 8 27 64…N)<\/strong> till the given number N in Python.<\/p>\nGiven Number (Limit) = 8<\/pre>\n
The above cube series till the given number{ 8 } is :\r\n1 8 27 64 125 216 343 512<\/pre>\n
Given Number (Limit) = 6<\/pre>\n
The above cube series till the given number{ 6 } is :\r\n1 8 27 64 125 216<\/pre>\n
Program To Print Cube Number Series 1 8 27 64…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 = 8\r\n# Take a variable to say itr and initialize its value to 1.\r\nitr = 1\r\nprint(\"The above cube 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 while loop, multiply the itr with itself 3 times and store it in\r\n # another variable.\r\n k = itr*itr*itr\r\n # Print the above result separated by spaces.\r\n print(k, end=\" \")\r\n # Increment the above itr value by 1.\r\n itr += 1\r\n<\/pre>\n
The above cube series till the given number{ 8 } is :\r\n1 8 27 64 125 216 343 512<\/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\nprint(\"The above cube 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 while loop, multiply the itr with itself 3 times and store it in\r\n # another variable.\r\n k = itr*itr*itr\r\n # Print the above result separated by spaces.\r\n print(k, end=\" \")\r\n # Increment the above itr value by 1.\r\n itr += 1\r\n<\/pre>\n
Enter some Random Number = 6\r\nThe above cube series till the given number{ 6 } is :\r\n1 8 27 64 125 216<\/pre>\n
\n