Quiz #5

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

How would I view data from the toilet paper column only? A.) *house_df['toilet_paper']* B.) *toilet_paper['house_df']* C.) *toilet_paper.house_df* D.) *house_df[toilet_paper]*

A.) *house_df['toilet_paper']*

Imagine you have the following number: num = 12.46271 And you want to use f-strings method to print the following output: 12.463 Focusing on the curly brackets portion of the code only, how would you create this output? Look closely, the differences are small! A.) *{num:.3f}* B.) *{num:f3}* C.) *{num:3}* D.) *{num:3f}*

A.) *{num:.3f}*

How would you change the dataframe such that it is sorted by the shampoo column in ascending order? A.) *house_df.sort_by('shampoo', order = 'ascending', inplace = True)* B.) *house_df.sort_values(by = 'shampoo', inplace = True)* C.) *house_df.sort_values(by = 'shampoo', ascending = FALSE, inplace = TRUE))* D.) *house_df.sort_values('shampoo', inplace = True*

B.) *house_df.sort_values(by = 'shampoo', inplace = True)*

How would you subset the dataframe to show observations for which toilet paper sales were greater than 11 and shampoo sales were less than 8? A.) *[house_df.toilet_paper > 11] & [house_df.shampoo < 8]* B.) *house_df[(house_df.toilet_paper > 11) & (house_df.shampoo < 8)]* C.) *(house_df.toilet_paper > 11) & (house_df.shampoo < 8)* D.) *house_df[house_df.toilet_paper > 11 & house_df.shampoo < 8]*

B.) *house_df[(house_df.toilet_paper > 11) & (house_df.shampoo < 8)]*

How would you subset your dataframe so that you only see the toilet paper and garbage bags columns? A.) *house_df('toilet_paper', 'garbage_bags')* B.) *house_df[['toilet_paper', 'garbage_bags']]* C.) *house_df['toilet_paper']['garbage_bags']* D.) *house_df['toilet_paper', 'garbage_bags']*

B.) *house_df[['toilet_paper', 'garbage_bags']]*

How would you subset the dataframe to show the three observations with the highest number of garbage bag sales? A.) *house_df = nlargest(3, 'garbage_bags')* B.) *nlargest = house_df[3, 'garbage_bags']* C.) *house_df.nlargest(3, 'garbage_bags')* D.) *house_df[nlargest = 3, 'garbage_bags']*

C.) *house_df.nlargest(3, 'garbage_bags')*

Imagine you have a text file, and the first line is: It was a bright cold day in April, and the clocks were striking thirteen. Next, assume that you've already read a few characters. How would you return to the start of the text file, and then read the first three words (It was a)? A. seek.my_file(0) my_str = my_file.read(8) print(my_str) B. my_file.seek(1) print(my_str, 8) C. my_file.seek(1) my_str = my_file.read(8) print(my_str) D. my_file.seek(0) my_str = my_file.read(8) print(my_str)

D. my_file.seek(0) my_str = my_file.read(8) print(my_str)

How would you subset the dataframe to view data for Mar10, specifically? A.) *house_df[date == 'Mar10']* B.) *house_df.date == 'Mar10'* C.) *house_df.date['date' == 'Mar10']* D.) *house_df[house_df.date == 'Mar10']*

D.) *house_df[house_df.date == 'Mar10']*

Imagine that I want to print some date and time information in a nicely formatted way. However, there is a problem with the code below. What is the problem? *print f("It is {month} the {day}th at {hour} o'clock")* a.) There should be curly brackets on the outside of the string, and parentheses around variables inside the string b.) *f *should be inside the parentheses c.) There is an apostrophe in the string d.) *print* and *f* should be combined into one command: *printf*

b.) *f *should be inside the parentheses

With respect to text files, what does the method *readlines( )* do? a.) It creates a list, such that each item in the list is a word from the text file b.) It creates a list, such that each item in the list is a line from the text file c.) It creates a string that contains all the lines in the text file d.) It reads an individual line of a text file

b.) It creates a list, such that each item in the list is a line from the text file


Set pelajaran terkait

Ch.1 BIO 271-01: Human Anatomy (UNCG)

View Set

C++ Interview: Technical Questions

View Set

Chapter 32: Skin Integrity and Wound Care PrepU

View Set

Criminal Law & Procedure Learning Questions

View Set

Chapter 8 Therapeutic Relationship, Chapter 3 Biological Basis for Understanding Psychiatric Disorders and Treatments, Chapter 7 The Nursing Process and Standards of Care for Psychiatric Mental Health Nursing, Chapter 9 Communication and the Clinical...

View Set