Python Function Table of Number from Start to End

By | April 16, 2021

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

Python program able function of a number from start 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.

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
 
Python GUI Multiplication Table

 87 total views,  1 views today

Leave a Reply

Your email address will not be published. Required fields are marked *