Page 38 - Informatics_Practices_Fliipbook_Class12
P. 38
2. What will be the output of the following code: [2023]
import pandas as pd
s1=pd.Series(data=2*(3,10))
print(s1)
Ans. 0 3
1 10
2 3
3 10
dtype: int64
3. Kavyanjali, a chemical analyst, needs to arrange data of few elements in the form of two series containing symbols and their
atomic numbers respectively. Thereafter, the data of these two series has to be arranged and displayed in the form of Data
Frame as shown below: [2023]
Symbol Atomic number
Hydrogen H 1
Helium He 2
Lithium Li 3
Beryllium Be 4
Help her in writing suitable Python code to complete the task.
Ans. import pandas as pd
idx=['Hydrogen','Helium','Lithium','Beryllium']
s1=pd.Series(['H','He','Li','Be'],index=idx)
s2=pd.Series([1,2,3,4],index=idx)
d={'Symbol':s1,'Atomic Number':s2}
df=pd.DataFrame(d)
print(df)
4. Which of the following statement is wrong? [2022]
a. Can't change the index of the Series.
b. We can easily convert the list, tuple, and dictionary into a series.
c. A Series represents a single column in memory.
d. We can create empty Series.
Ans. a. Can't change the index of the Series.
5. What type of error is returned by the following statement? [2022]
import pandas aa pa
pa.Series([l,2,3,4], index = [ 'a' ,'b' ,' c' ] )
a. Value Error b. Syntax Error c. Name Error d. Logical error
Ans. a. Value Error
6. Consider the following code: [2022]
import numpy aa np
import pandas aa pd
L=np.array ([l0,20])
x=pd.Series(__________) # statement 1
print(x)
24 Touchpad Informatics Practices-XII

