Mathematical Operations Between Lists

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
Aman Kharwal
Aman Kharwal

Data Strategist at Statso. My aim is to decode data science for the real world in the most simple words.

Articles: 1607

Leave a Reply

Discover more from thecleverprogrammer

Subscribe now to keep reading and get access to the full archive.

Continue reading