## A function that prints out tables from 1 to 10 using iteration

write a python program print the table in of 1 to 10 using while loop.
print table in python
program to print multiplication table of a given number in python
multiplication table in python using for loop
8.5.1: print multiplication table
multiplication table in python using lambda function
we will provide you with a number n. output the times table for that number from 1 to 12.
python program to print table of a given number
```def tablesOneToTen():  # a function that will print out multiplication tables from 1-10
x = 1
y = 1
while x <= 10 and y <= 12:
f = x * y
print(f)
y = y + 1
x = x + 1

tablesOneToTen()
```

I am trying to make a function that will give me values from the multiplication table from `1-10`.

Should I add `if` and `elif` statements in addition to nested `while` loops to make this code work?

For these sort of iteration tasks you're better off using the `for` loop since you already know the boundaries you're working with, also Python makes creating `for` loops especially easy.

With `while` loops you have to check that you are in range using conditionals while also explicitly incrementing your counters making mistakes all the more likely.

Since you know you need multiplication tables for values of `x` and `y` ranging from `1-10` you can, to get you familiar with loops, create two `for` loops:

```def tablesOneToTen():  # a function that will print out multiplication tables from 1-10
# This will iterate with values for x in the range [1-10]
for x in range(1, 11):
# Print the value of x for reference
print("Table for {} * (1 - 10)".format(x))
# iterate for values of y in a range [1-10]
for y in range(1, 11):
# Print the result of the multiplication
print(x * y, end=" ")
# Print a new Line.
print()
```

Running this will give you the tables you need:

```Table for 1 * (1 - 10)
1 2 3 4 5 6 7 8 9 10
Table for 2 * (1 - 10)
2 4 6 8 10 12 14 16 18 20
Table for 3 * (1 - 10)
3 6 9 12 15 18 21 24 27 30
```

With a `while` loop, the logic is similar but of course just more verbose than it need to since you must initialize, evaluate the condition and increment.

As a testament to its uglyness, the `while` loop would look something like this:

```def tablesOneToTen():
# initialize x counter
x = 1

# first condition
while x <= 10:
# print reference message
print("Table for {} * [1-10]".format(x))
# initialize y counter
y = 1
# second condition
while y <=10:
# print values
print(x*y, end=" ")
# increment y
y += 1
# print a new line
print(" ")
# increment x
x += 1
```

Python Program to Display the multiplication Table, Source code to print multiplication table of a number entered by user in Multiplication table (from 1 to 10) in Python num = 12 # To take input from the user Here, we have used the for loop along with the range() function to iterate 10 times. Next, we used Nested For Loop to iterate j from 1 to 10. User entered value: number = 9. First For Loop – First Iteration: for(i = 9; i < 10; i++) Condition is True. So, it enters into the second For Loop. Second For Loop – First Iteration: for(j = 1; 1 <= 10; 1++) Condition is True. So, the statement inside the system.out.println printed.

Using `Python 3`

```for i in range(1, 10+1):
for j in range(i, (i*10)+1):
if (j % i == 0):
print(j, end="\t")
print()
```

or:

```for i in range(1, 10+1):
for j in range(i, (i*10)+1, i):
print(j, end="\t")
print()
```

Output:

```1   2   3   4   5   6   7   8   9   10
2   4   6   8   10  12  14  16  18  20
3   6   9   12  15  18  21  24  27  30
4   8   12  16  20  24  28  32  36  40
5   10  15  20  25  30  35  40  45  50
6   12  18  24  30  36  42  48  54  60
7   14  21  28  35  42  49  56  63  70
8   16  24  32  40  48  56  64  72  80
9   18  27  36  45  54  63  72  81  90
10  20  30  40  50  60  70  80  90  100
```

Python Exercise: Create the multiplication table of a number , Python Exercise: Create the multiplication table of a number use for loop to iterate 10 times for i in range(1,11): print(n,'x',i,'=',n*i) It's been pointed out to me in the comments that because this answer is heavily referenced,  Input a number from user to generate multiplication table. Store it in some variable say num. To print multiplication table we need to iterate from 1 to 10. Run a loop from 1 to 10, increment 1 on each iteration.

```a = [1,2,3,4,5,6,7,8,9,10]

for i in a:
print(*("{:3}" .format (i*col) for col in a))
print()
```

Python Program to Print Multiplication Table of a given Number, In the program, user is asked to enter the number and the program prints the multiplication table of the input number using for loop. The loops run from 1 to 10​  Print Multiplication table of a given number In the program, user is asked to enter the number and the program prints the multiplication table of the input number using for loop. The loops run from 1 to 10 and the input number is multiplied by the loop counter in each step to display the steps of multiplication table.

6. Iteration, In Python, an assignment statement can make two variables equal, but they don't have to stay that 1 evaluates to True, the loop body is again executed, and 10 is printed. Let's say you want to print a multiplication table for the values from 1 to 6. When we get the code working, we extract it and wrap it up in a function. Here, we have used the for loop along with the range () function to iterate 10 times. The arguments inside the range () function are (1, 11). Meaning, greater than or equal to 1 and less than 11. We have displayed the multiplication table of variable num (which is 12 in our case).

7. Iteration, Let us write a function now to sum up all the elements in a list of numbers. Do this by 1 evaluates to True, the loop body is again executed, and 10 is printed. 10 % 2 Let's say you want to print a multiplication table for the values from 1 to 6. The for loop prints the number from 1 to 10 using the range () function here i is a temporary variable which is iterating over numbers from 1 to 10. It’s worth mentioning that similar to list indexing in range starts from 0 which means range (j) will print sequence till (j-1) hence the output doesn’t include 6.

R Program to Display a Multiplication Table, In this example, you will learn to print the multiplication table of a number a number: ")) # use for loop to iterate 10 times for(i in 1:10) { print(paste(num,'x', i, '='​  Here, we ask the user for a number which is stored in num variable. Then, the for loop is iterated 10 times from i equals to 1 to i equals to 10. In each iteration, a row of the multiplication table is printed using: print (paste (num,'x', i, '=', num*i))

• Start by getting your indentation straight: `x` never changes inside the `while` loop, at least as the code has been posted.
• You need two loops. `x` needs to keep starting from `1` again.