Mathematical Operations Between Lists

Addition, subtraction, multiplication and division between lists in python.

Addition of two lists

list1 = [1, 2, 3, 4]
list2 = [4, 3, 2, 1]
for i in list2:
    for j in list1:
        print(i,"+",j,"=",i+j)
#Output

Subtraction of two lists

list1 = [1, 2, 3, 4]
list2 = [4, 3, 2, 1]
for i in list2:
    for j in list1:
        print(i,"-",j,"=",i-j)

#Output

Division of two lists

list1 = [1, 2, 3, 4]
list2 = [4, 3, 2, 1]
for i in list2:
    for j in list1:
        print(i,"/",j,"=",i/j)

#Output

Multiplication of two lists

list1 = [1, 2, 3, 4]
list2 = [4, 3, 2, 1]
for i in list2:
    for j in list1:
        print(i,"x",j,"=",i*j)

#Output
Default image
Aman Kharwal

I am a programmer from India, and I am here to guide you with Data Science, Machine Learning, Python, and C++ for free. I hope you will learn a lot in your journey towards Coding, Machine Learning and Artificial Intelligence with me.

Leave a Reply

Data Science | Machine Learning | Python | C++ | Coding | Programming | JavaScript