CLASS 12 SERIES WORKSHEET NO 3
solution
QUESTION NO 1 Create a Series object S1 using a python sequence [2,4,6,8] and default indices.
QUESTION NO 2 Write the output of the following code fragment.
import pandas as pd
s2=pd.Series(["i","am", "a","student"])
print(s2)
QUESTION NO 3 Write the output of the following code fragment.
import pandas as pd
s1=pd.Series(200,index=range(2,13,2))
print(s1)
QUESTION NO 4 Write the output of the following code fragment.
import pandas as pd
s1=pd.Series(range(2,11,2), index=[x for x in "abcde"])
print(s1)
QUESTION NO 5 Write the output of the following code fragment.
import pandas as pd
import numpy as np
x=np.arange(10,15)
s3=pd.Series(index=x, data=x*2)
s4=pd.Series(x**2,x)
print(s3)
print(s4)
QUESTION NO 6 Write the output of the following code fragment.
import pandas as pd
import numpy as np
x=np.arange(10,15)
s3=pd.Series(index=x, data=x*2)
s4=pd.Series(x**2,x)
print(s3)
print(s4)
QUESTION NO 7 Sequences section and contribution store the section name ( 'A','B','C','D','E') and contribution (8900,8700,7800,6500,nil) for charity. Your school has decided to donate more contribution by each section, so donation has been doubled. Write code to create series object that stores the contribution amount as the values and section name as indexes with data type as float32.
QUESTION NO 8 Write the output of the following code fragment.
import pandas as pd
import numpy as np
val1=np.arange(5.25,50,10.25)
ser1=pd.Series(val1,index=['a','b','a','a','b'])
print(ser1)
print(ser1['a'])
print(ser1['b'])
QUESTION NO 9 Consider a series object s10 that stores the number of students in each section of class 12 as shown below. First two sections have been given task for selling tickets @ Rs.100/- per ticket as a part of social experiment. Write code to create the series and display how much section A and B have collected.
A 39
B 31
C 32
D 34
E 35
QUESTION NO 10 Consider the series s4 as given below
0 2.50
1 17.45
2 20.25
3 87.25
4 33.76
What will be the output after executing the following:
S4[0]=1.75
S4[2:4]= -23.74
print(S4)
0 Comments