Thursday, 11 March 2021

Class 12 IP Practical - 13

 13.  WAP to perform mathematical operation addition, subtraction and multiplication on two series.

 


import pandas as pd

d1=[10,20,30,40,50,60,70,80]

S1=pd.Series(d1)

d2=[1,2,3,4,5,6,7,8]

S2=pd.Series(d2)

print("First Series:")

print(S1)

print("2nd Series:")

print(S2)

print("Addition of S1+S2 Series:")

print(S1.add(S2))

print("Subtraction of S1-S2 Series:")

print(S1.sub(S2))

print("Multiplication of S1*S2 Series:")

print(S1.mul(S2))



>>>

========= RESTART: C:/Program Files (x86)/Python38-32/Ip-13.py ========

First Series:

0    10

1    20

2    30

3    40

4    50

5    60

6    70

7    80

dtype: int64

2nd Series:

0    1

1    2

2    3

3    4

4    5

5    6

6    7

7    8

dtype: int64

Addition of S1+S2 Series:

0    11

1    22

2    33

3    44

4    55

5    66

6    77

7    88

dtype: int64

Subtraction of S1-S2 Series:

0     9

1    18

2    27

3    36

4    45

5    54

6    63

7    72

dtype: int64

Multiplication of S1*S2 Series:

0     10

1     40

2     90

3    160

4    250

5    360

6    490

7    640

dtype: int64

>>> 


No comments:

Post a Comment