Fundamentals 3 min read

How to Copy Lists and Generate a 9×9 Multiplication Table in Python

This article demonstrates two basic Python examples: copying a list using slicing and printing the full 9×9 multiplication table with nested loops, including the complete source code and expected output for each case.

Python Programming Learning Circle
Python Programming Learning Circle
Python Programming Learning Circle
How to Copy Lists and Generate a 9×9 Multiplication Table in Python

Example 1

Task: Copy the data from one list to another.

Analysis: Use list slicing (list[:]).

#!/usr/bin/python
# -*- coding: UTF-8 -*-

a = [1, 2, 3]
b = a[:]
print(b)

Output:

[1, 2, 3]

Example 2

Task: Print the 9×9 multiplication table.

Analysis: Use two nested loops, with i controlling rows and j controlling columns.

#!/usr/bin/python
# -*- coding: UTF-8 -*-

for i in range(1, 10):
    for j in range(1, 10):
        result = i * j
        print('%d * %d = % -3d' % (i, j, result))
    print('')

Sample output (partial):

1 * 1 =   1
1 * 2 =   2
1 * 3 =   3
1 * 4 =   4
1 * 5 =   5
1 * 6 =   6
1 * 7 =   7
1 * 8 =   8
1 * 9 =   9

2 * 1 =   2
2 * 2 =   4
2 * 3 =   6
2 * 4 =   8
2 * 5 =  10
2 * 6 =  12
2 * 7 =  14
2 * 8 =  16
2 * 9 =  18

... (continues for rows 3 through 9) ...
Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Slicingnested loopsbasic programminglist copyingmultiplication table
Python Programming Learning Circle
Written by

Python Programming Learning Circle

A global community of Chinese Python developers offering technical articles, columns, original video tutorials, and problem sets. Topics include web full‑stack development, web scraping, data analysis, natural language processing, image processing, machine learning, automated testing, DevOps automation, and big data.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.