Question: python coding: Questions Recall that last time in-class we used of if and elif statements to do grouping of the gasoline retail data into bins.
python coding:
Questions
Recall that last time in-class we used of if and elif statements to do grouping of the gasoline retail data into bins. In particular, we wrote code that counted how many months of retail sales fell between (all in millions of $) 30,000--32,000, 32,000--34,000, 34,000--36,000, 36,000--38,000, and 38,000--40,000. Here's the code we wrote:
num_bin1 = 0 num_bin2 = 0 num_bin3 = 0 num_bin4 = 0 num_bin5 = 0 for idata in data_2015: if (idata >= 30000) and (idata < 32000): num_bin1 += 1 elif (idata >= 32000) and (idata < 34000): num_bin2 += 1 elif (idata >= 34000) and (idata < 36000): num_bin3 += 1 elif (idata >= 36000) and (idata < 38000): num_bin4 += 1 elif (idata >= 38000) and (idata < 40000): num_bin5 += 1 else: print("Out of range") How would we change that code so instead of having multiple elif statements we only make use of a single if statement to do all our grouping (ignoring the else check for out-of-range values)? Try to write this improved code. Remember this PCA is graded on effort, so you need to show your work, not necessarily get the right answer.
What does it mean to sort something? Please describe this in your own words.
If you haven't yet, watch the video on selection sort that linked in the Simple Data Analysis homework. Describe, in your own words, how selection sort works.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
