Click here to download

Get Table of any number with user input in python

 

TABLE OF ANY NUMBER HERE:

Enter the number whose table you want 👇

Generate Table




Table Program in Python

This article will write the table programs using loops (for, do-while, and while loop) and functions (user-defined and recursion function) in the Python programming language.

A table (or multiplication table) of numbers is generated by multiplying a constant number with an iterative number from 1 to 10 to get the table. In other words, we can get the table of a number by multiplying the given number with counting from 1, 2, 3, 4, 5, ..., 9, 10. And on each iteration, the value of counting is incremented by 1, which goes up to 10, to print a complete table.

For example, suppose we want to write the table of 5 in Python language. So, first, we take 5 as input from the user, and then, we use a loop or function that multiplies the number 5 by 1 (5 * 1), and then (5 * 2), (5 * 3), to the last (5 * 10) number, to get the complete table of the given numbers.


Different ways to generate the table program:

Following are the various ways to generate the table program in the python programming language.

  1. Using for loop
  2. Using while loop
  3. Using do-while loop
  4. Using user-defined function
  5. Using recursion function
  6. Using if and goto statement
  7. Using for loop and pointer
  8. Using nested for loop

Program to generate the table of a given number using for loop

Let's consider an example to print the table of the specific number using for loop in the python programming language

  1. #My python code for a table with user input:

    def table_n(n):
        for i in range(0,10):
            sum = n*i +n
            i += 1
            print(n , "*" , i ,"= " ,sum)
    n = int(input("Enter the number whose table you want."))
    table_n(n)

No comments

Buy Here   Brand ‎Apple Manufacturer ‎Apple, Apple Inc, One Apple Park Way, Cupertino, CA 95014, USA. or Apple India Private Limited No.24, ...