BADM /
211 -
/ // /
Final
/ /
Exam
/ /
(UIUC) Questions With Correct Answers
/ // // // //
A/
/list /
/can //contain //any //Python //type. //But //a //list //itself //is //also //a //Python //type. //That //means //that //a
//list /
/can /
/also /
/contain //
a/
/list! /
/Python /
/is /
/getting /
/funkier /
/by //the //minute, //but //fear //not, //just //remember //the //list //syntax: //(Python //List //Assignment)
my_list //= //[el1, //el2, //el3]
Can /
/you /
/tell /
/which //ones //of //the //following //lines //of //Python //code //are //valid //ways //to //build //a //list? //Please
//choose //all //correct //answers. //- //CORRECT //ANSWERS(S)✔✔a. //[[1, //2, //3], //[4, //5, //7]]
b. //[1 //+ //2, //"a" //* //5, //3]
c. //[1, //3, //4, //2]
**d. //All //of //the //above
,Assume, //you //are //given //two //lists:
a //= //[1,2,3,4,5]
b //= //[6,7,8,9]
The //task //is //to //create //a //list //which //has //all //the //elements //of //a //and //b //in //one //dimension.
Output:
a //= //[1,2,3,4,5,6,7,8,9]
Which /
/of /
/the /
/following /
/options //would //you //choose? //(Python //List) //- //CORRECT //ANSWERS(S)✔✔a. //a.join(b)
b. //a //"+" //b
c. //a.append(b)
**d. //a.extend(b)
You /
/want /
/to /
/print /
/the //top //5 //ids //with //highest //income //from //this //dataset //(dataframe //shows //a //partial //view):
What /
/should /
/be /
/the /
/correct /
/sequence //of //commands? //(Data //Manipulation //with //Pandas) //- //CORRECT //ANSWERS(S)✔✔a.
//df.sort_values(), //df.head()
b. //df.head(), //df.sort_values()
**c. //df.sort_values("Income"), //df.head()
,d. //df.sort_values("Age"), //df.head()
Filter /
/all /
/the //rows //where //age //is //less //than //40 //in //this //dataset //(Data //Manipulation //with //Pandas).
Choose //all //correct //answers. //- //CORRECT //ANSWERS(S)✔✔a. //df.filter('Age')<40
**b. //df[df.age<40]
c. //df.sort_values("Age")<40
**d. //df //[df['Age']<40]
Get /
/the /
/proportion /
/of /
/male /
/and /
/female /
/entries /
/in /
/this /
/dataset /
/(Data //Manipulation //with //Pandas). //- //CORRECT //ANSWERS(S)✔✔a. //df["Gender"].numbers()
**b. //df //["Gender"].value_counts(normalize=True)
c. //df["Gender"].counts()
d. //df["Gender"].value_counts()
Complete /
/the /
/following /
/command /
/to /
, /get /
/the //mean //income //of //each //gender //from //this //dataset. //(Data //Manipulation //with //Pandas)
Complete //this //command:
df.______ //("_____")
["______"].mean() //- //CORRECT //ANSWERS(S)✔✔a. //groupby, //age, //income
b. //groupby, //age, //gender
c. //groupby, //income, //gender
**d. //groupby, //gender, //income
You /
/have /
/the /
/following /
/dataframe /
/df: //(Data //Manipulation //with //Pandas) //- //CORRECT //ANSWERS(S)✔✔a. //print(df.iloc([2:3])
b. //print(df.iloc[3:]
c. //print(df.iloc([0:3])
**d. //print(df.iloc[1:3])
Match /
/the /
/variable /
/on //the //left //with //its //datatype //on //the //right. //- //CORRECT //ANSWERS(S)✔✔p=3 //-- //int
q="False" //-- //str
r=True //-- //bool
Suppose /
/you /
/have /
211 -
/ // /
Final
/ /
Exam
/ /
(UIUC) Questions With Correct Answers
/ // // // //
A/
/list /
/can //contain //any //Python //type. //But //a //list //itself //is //also //a //Python //type. //That //means //that //a
//list /
/can /
/also /
/contain //
a/
/list! /
/Python /
/is /
/getting /
/funkier /
/by //the //minute, //but //fear //not, //just //remember //the //list //syntax: //(Python //List //Assignment)
my_list //= //[el1, //el2, //el3]
Can /
/you /
/tell /
/which //ones //of //the //following //lines //of //Python //code //are //valid //ways //to //build //a //list? //Please
//choose //all //correct //answers. //- //CORRECT //ANSWERS(S)✔✔a. //[[1, //2, //3], //[4, //5, //7]]
b. //[1 //+ //2, //"a" //* //5, //3]
c. //[1, //3, //4, //2]
**d. //All //of //the //above
,Assume, //you //are //given //two //lists:
a //= //[1,2,3,4,5]
b //= //[6,7,8,9]
The //task //is //to //create //a //list //which //has //all //the //elements //of //a //and //b //in //one //dimension.
Output:
a //= //[1,2,3,4,5,6,7,8,9]
Which /
/of /
/the /
/following /
/options //would //you //choose? //(Python //List) //- //CORRECT //ANSWERS(S)✔✔a. //a.join(b)
b. //a //"+" //b
c. //a.append(b)
**d. //a.extend(b)
You /
/want /
/to /
/print /
/the //top //5 //ids //with //highest //income //from //this //dataset //(dataframe //shows //a //partial //view):
What /
/should /
/be /
/the /
/correct /
/sequence //of //commands? //(Data //Manipulation //with //Pandas) //- //CORRECT //ANSWERS(S)✔✔a.
//df.sort_values(), //df.head()
b. //df.head(), //df.sort_values()
**c. //df.sort_values("Income"), //df.head()
,d. //df.sort_values("Age"), //df.head()
Filter /
/all /
/the //rows //where //age //is //less //than //40 //in //this //dataset //(Data //Manipulation //with //Pandas).
Choose //all //correct //answers. //- //CORRECT //ANSWERS(S)✔✔a. //df.filter('Age')<40
**b. //df[df.age<40]
c. //df.sort_values("Age")<40
**d. //df //[df['Age']<40]
Get /
/the /
/proportion /
/of /
/male /
/and /
/female /
/entries /
/in /
/this /
/dataset /
/(Data //Manipulation //with //Pandas). //- //CORRECT //ANSWERS(S)✔✔a. //df["Gender"].numbers()
**b. //df //["Gender"].value_counts(normalize=True)
c. //df["Gender"].counts()
d. //df["Gender"].value_counts()
Complete /
/the /
/following /
/command /
/to /
, /get /
/the //mean //income //of //each //gender //from //this //dataset. //(Data //Manipulation //with //Pandas)
Complete //this //command:
df.______ //("_____")
["______"].mean() //- //CORRECT //ANSWERS(S)✔✔a. //groupby, //age, //income
b. //groupby, //age, //gender
c. //groupby, //income, //gender
**d. //groupby, //gender, //income
You /
/have /
/the /
/following /
/dataframe /
/df: //(Data //Manipulation //with //Pandas) //- //CORRECT //ANSWERS(S)✔✔a. //print(df.iloc([2:3])
b. //print(df.iloc[3:]
c. //print(df.iloc([0:3])
**d. //print(df.iloc[1:3])
Match /
/the /
/variable /
/on //the //left //with //its //datatype //on //the //right. //- //CORRECT //ANSWERS(S)✔✔p=3 //-- //int
q="False" //-- //str
r=True //-- //bool
Suppose /
/you /
/have /