Python Function Print Table of Number Start to End – this Python program will display a table of the given number from starting value to ending value.

## How Python table Function program will work?

First of all, it will ask the user to input the number, start and end value.

The program will pass these three values to the function table(). The table function will print the required table of the given number from start ton ending value.

### Explanation of Print Table Function

def print_table(num, start, end): """ This function prints multiplication table of a given number""" for i in range(start, end+1): print(num,' x ', i, ' = ',num*i)

- Use def keyword to define function header with name print_table and 3 parameters in parentheses. You will end the function header by a colon.
- Write down a doc string in first line of the function to describe the purpose of this function.
- Now use a for loop to display the table of the given number from start value to end value provided through arguments in the function call.
- We will use a range given by start to end inclusive.
- Use a print() function in loop body to print one line of table as follows
- 4 x 1 = 4

## Source Code of Python program Table Function of given number Start To End

# An example Python program # to define and call a function table of # a number # to show multiplication table of a number # from a start value to ending value. # Author : www.EasyCodebook.com (c) # Note the first line in function is called # document string, # define the function with formal parameter num def print_table(num, start, end): """ This function prints multiplication table of a given number""" for i in range(start, end+1): print(num,' x ', i, ' = ',num*i) # end of function table # input a number n = int(input("Please Enter a number to print its multiplication table:")) start = int(input("Enter start value to start printing table from:")) end = int(input("Enter end value to stop printing table:")) # call the function tanle by passing actual parameter 'n' print_table(n, start, end)

## Output

Please Enter a number to print its multiplication table:7 Enter start value to start printing table from:1 Enter end value to stop printing table:15 7 x 1 = 7 7 x 2 = 14 7 x 3 = 21 7 x 4 = 28 7 x 5 = 35 7 x 6 = 42 7 x 7 = 49 7 x 8 = 56 7 x 9 = 63 7 x 10 = 70 7 x 11 = 77 7 x 12 = 84 7 x 13 = 91 7 x 14 = 98 7 x 15 = 105