Write a Python to print 2 table.

Write a Python to print 2 table.

 Sure! Here's a simple Python program to print the 2 times table:

python

Copy code

for i in range(1, 11):

    print("2 x", i, "=", 2*i)


This program uses a for loop to iterate over the numbers 1 to 10, and then multiplies each number by 2 to get the corresponding value in the 2 times table. The print statement then displays the equation and the result.


You can modify the range function to print any other times table, just replace the number 2 with the desired number. For example, if you want to print the 5 times table, you can modify the code like this:


python

Copy code


for i in range(1, 11):

    print("5 x", i, "=", 5*i)


I hope this helps!

1 Comments

  1. num = 2
    for i in range(1, 11):
    print(f"{num} x {i} = {num*i}")

    ReplyDelete
Previous Post Next Post