16.11. Mixed Up Code Practice

Try to solve each of the following. Click the Check Me button to check each solution. You will be told if your solution is too short, has a block in the wrong order, or you are using the wrong block. Some of the problems have one or more extra blocks that aren’t needed in the correct solution. Try to solve these on your phone or other mobile device!

The following program segment should swap the first and last values of the list “numbers” using indexing. But, the blocks have been mixed up and include an extra block that isn’t needed in the solution. Drag the needed blocks from the left and put them in the correct order on the right. Click the <i>Check Me</i> button to check your solution.</p>

The following program segment should iterate through the list of prices and discount them by 50%. But, the blocks have been mixed up and include an extra block that isn’t needed in the solution. Drag the needed blocks from the left and put them in the correct order on the right. Click the <i>Check Me</i> button to check your solution.</p>

The following program segment should iterate through the strings in <i>list</i> and append them to <i>long_list</i> if the length is greater than 4. But, the blocks have been mixed up and include an extra block that isn’t needed in the solution. Drag the needed blocks from the left and put them in the correct order on the right. Click the <i>Check Me</i> button to check your solution.</p>

The following program segment should first replace the last item of the list <i>months</i> with “November” then append “December” to the end of the list. But, the blocks have been mixed up and include extra blocks that aren’t needed in the solution. Drag the needed blocks from the left and put them in the correct order on the right. Click the <i>Check Me</i> button to check your solution.</p>

The following program segment should iterate through the list <i>terms</i> and then add each item to the list <i>vocab</i> if it is not already in the list. If the word is already in <i>vocab</i>, then the program should add 1 to the variable “counter”. But the blocks have been mixed up and include extra blocks that aren’t needed in the solution. Drag the needed blocks from the left and put them in the correct order on the right. Click the <i>Check Me</i> button to check your solution.</p>

The following program segment should reverse the order of the list <i>oldList</i>, by storing it in the list <i>soFar</i>. Print the result at the end. The blocks have been mixed up and include extra blocks that aren’t needed in the solution. Drag the needed blocks from the left and put them in the correct order on the right. Click the <i/>Check Me</i> button to check your solution.</p>

The following program segment should first print out the program’s instructions. Next it should continuously ask the user if it wants to add a word to a list <i>vocabulary</i> and then append it to the end the list IF the word is not already in the list. The blocks have been mixed up and include extra blocks that aren’t needed in the solution. Drag the needed blocks from the left and put them in the correct order on the right. Click the <i>Check Me</i> button to check your solution.</p>

You have attempted of activities on this page