17.10. 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 an extra block that isn’t needed in the correct solution. Try to solve these on your phone or other mobile device!
The following program segment should split the string “phrase” by each word and assign the result to variable “x”. Then insert the word “Jordan” into the string <i>final</i> and print the result. 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 print the integers <i>4, 9, 12</i> in order using the find method on <i>str</i>. 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 take the name from <i>sent_1</i> and assign it to the variable <i>first_name</i> using indexing. Then add the string to the variable <i>last_name</i> to create the variable <i>full_name</i>. Finally, add <i>full_name</i> to the <i>favorite</i> and print the result. 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 print the integer <i>7</i> using the .find() procedure. 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>
A restaurant needs to print out the correct total for customer #1, but all they have is a string of totals. The correct total for customer #1 is 70. The string <i>totals</i> includes the totals of the last 5 customers, separated by parentheses. Use the split and index methods to print out the proper total for customer #1. 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 define and then call the function <i>storyTime</i> which uses variables to piece together a story. 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 function should take in two strings as arguments, then print and return the position of the first parameter in the second string. 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>