Skip to main content

Print Multiplication Tables in Python

# -*- coding: utf-8 -*-

#Created on Sat Sep 21 10:24:49 2019

# @author: MEGHA


m = int(input("How many tables you want to print?"))

n = int(input("How many tables you want to print in each row?"))

p = int(input("How many terms you want in each table?" ))

print ("\nThe MultiPlication Tables are")

print ("****************************** ")

for x in range (1,m,n):

    for y in range (1,p+1):

        for z in range (1,n+1,1) :

            if x+z-1 <= m :

                print (str(y) + " * " +str( x+z-1) + " = "+str(y*(x+z-1)), end = "\t ")

        print("")

    print("")

# end


Result:

How many tables you want to print?15

How many tables you want to print in each row?5

How many terms you want in each table?2

The MultiPlication Tables are

****************************** 

1 * 1 = 1         1 * 2 = 2         1 * 3 = 3          1 * 4 = 4          1 * 5 = 5  

2 * 1 = 2         2 * 2 = 4         2 * 3 = 6         2 * 4 = 8          2 * 5 = 10  


1 * 6 = 6          1 * 7 = 7         1 * 8 = 8         1 * 9 = 9         1 * 10 = 10  

2 * 6 = 12 2 * 7 = 14 2 * 8 = 16 2 * 9 = 18 2 * 10 = 20  


1 * 11 = 11 1 * 12 = 12 1 * 13 = 13 1 * 14 = 14 1 * 15 = 15  

2 * 11 = 22 2 * 12 = 24 2 * 13 = 26 2 * 14 = 28 2 * 15 = 30


Comments

Popular posts from this blog

Python OOPs Concepts: Using Variables and Methods

  Types of Variables in OOPs Python   Instance Variable Static Variable Local Variable   Object Level Variables Class Level Variables Method Level Variables When to use: For Every Object if you want Separate copy, use Instance Variables For all object one copy is required, use static variables Inside method, Just used for temporary requirement Where to Declare Inside the constructor method (in general) Within the class directly, outside of methods (in general)   Within the method only. How to Declare Within the constructor: Instance variables can be declared within the constructor method using the self .   Using default values : Instance variables can be assigned default values during initialization.   Outside the class: use object name.   · ...

Polymorphism: Method Overloading vs Method Overriding

  Method Overloading In object-oriented programming languages, method overloading enables a class to have several methods with the same name but different parameters. However, in Python, method overloading is not directly supported as opposed to languages such as Java or C++. This is because Python allows developers to define default arguments for their methods and pass arguments of any type to a method. This flexibility allows a single method to handle various types of arguments, eliminating the need for overloading.   However, there is a way to simulate method overloading in Python by using default argument values or variable length arguments and conditional statements. Here's an example: Program using default arguments:       Program using variable length arguments:   Multiple methods with Same Name: When we define multiple methods with same name, Python will consider the last defined method only. Python will not support method overload...

Is Li-Fi Better than Wi-Fi?

Li-Fi  ( light fidelity )  is a bidirectional wireless system that transmit data to the devices like mobiles, laptop, etc., via infrared light or LED. The device has a receiver to pick up light signals and a transmitter to send light signal back to the lamp using infrared light or LED. It was first unveiled in 2011 and, unlike Wi-Fi, which uses radio frequency, Li-Fi technology only needs a light source with a chip to transmit an internet signal through light waves. Light fidelity (LiFi) is a faster, more secure and efficient wireless connection that uses light waves to transmit data Li-Fi technology still has a long way to go before worldwide adoption but every year, we are getting nearer to enjoying it for ourselves. The future surely looks bright with LiFi. How LiFi Works? LiFi makes use of visible light through overhead lighting for the transmission of data. This is possible through the use of a Visible Light Communications (VLC) system for data transmission. A VLC system ...