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

I'm a writer and data scientist on a mission to educate others about the incredible power of data📈.

Articles: 1431

Leave a Reply