|
| 1 | +Introduction to Problem Types |
| 2 | +============================= |
| 3 | + |
| 4 | +Please read the following, watch the videos, and try to solve the problems. |
| 5 | + |
| 6 | + |
| 7 | +Solving Mixed-up Code Problems |
| 8 | +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 9 | + |
| 10 | +If you see a problem like the one below you will need to put the mixed-up |
| 11 | +code in the correct order on the right side. You |
| 12 | +may need to indent the blocks as well. There may also be extra blocks that are not |
| 13 | +needed in a correct solution that you can leave on the left side. Click the "Check" button |
| 14 | +to check your solution. |
| 15 | + |
| 16 | +See the video below for an example. |
| 17 | + |
| 18 | +.. youtube:: Rf7oWHlo-e0 |
| 19 | + :divid: iwgex1-parsons1-mooc_nested |
| 20 | + :optional: |
| 21 | + :width: 650 |
| 22 | + :height: 415 |
| 23 | + :align: center |
| 24 | + |
| 25 | +Try to solve the following mixed-up code problem. This problem doesn't require any indentation. |
| 26 | + |
| 27 | +.. parsonsprob:: intro-simple-parsons-no-indent-mooc_nested |
| 28 | + :numbered: left |
| 29 | + :adaptive: |
| 30 | + :practice: T |
| 31 | + :order: 3, 1, 2, 0 |
| 32 | + |
| 33 | + Drag the blocks from the left and put them in the correct order on the right. The text in each block |
| 34 | + defines the order. |
| 35 | + ----- |
| 36 | + First block |
| 37 | + ===== |
| 38 | + Second block |
| 39 | + ===== |
| 40 | + Third block |
| 41 | + |
| 42 | +Try to solve the following mixed-up code problem. This problem requires indentation. |
| 43 | + |
| 44 | +.. parsonsprob:: intro-simple-parsons-indent-mooc_nested |
| 45 | + :numbered: left |
| 46 | + :adaptive: |
| 47 | + :practice: T |
| 48 | + :order: 3, 1, 2, 0 |
| 49 | + |
| 50 | + Drag the blocks from the left and put them in the correct order on the right with the correct indentation. |
| 51 | + The text in each block defines the order and indentation. |
| 52 | + ----- |
| 53 | + First block |
| 54 | + ===== |
| 55 | + Second block |
| 56 | + ===== |
| 57 | + Third block that needs to be indented |
| 58 | + |
| 59 | +Try to solve the following mixed-up code problem. This problem requires indentation and has extra blocks that are not needed in a correct solution. |
| 60 | + |
| 61 | +.. parsonsprob:: intro-simple-parsons-indent-with-dist-mooc_nested |
| 62 | + :numbered: left |
| 63 | + :adaptive: |
| 64 | + :practice: T |
| 65 | + :order: 3, 1, 2, 0 |
| 66 | + |
| 67 | + Drag the blocks from the left and put them in the correct order on the right with the correct indentation. |
| 68 | + There is an extra block that is not needed in the correct solution. |
| 69 | + ----- |
| 70 | + First block |
| 71 | + ===== |
| 72 | + Second block |
| 73 | + ===== |
| 74 | + Extra block that is not needed #paired: This block is not needed |
| 75 | + ===== |
| 76 | + Third block that needs to be indented |
| 77 | + |
| 78 | +The mixed-up code problems have a "Help me" button at the bottom of the |
| 79 | +problem. Once you have checked at least three incorrect solutions you can |
| 80 | +click the button for help. It will remove an incorrect code block, if you used |
| 81 | +one in your solution, or combine two blocks into one if there are more |
| 82 | +than three blocks left. |
| 83 | + |
| 84 | +See the video below for an example. |
| 85 | + |
| 86 | +.. youtube:: QejZ7u642IU |
| 87 | + :divid: iwgex1-parsons2-mooc_nested |
| 88 | + :optional: |
| 89 | + :width: 650 |
| 90 | + :height: 415 |
| 91 | + :align: center |
| 92 | + |
| 93 | +Solving Write Code Problems |
| 94 | +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 95 | + |
| 96 | +If you see a problem like the one below, you will need to write code. The problem |
| 97 | +will have unit tests that you can run to check that your code is working |
| 98 | +correctly. Click on the "Run" button to compile and run your code. Look after |
| 99 | +the code area for compiler errors and/or unit test results. |
| 100 | + |
| 101 | +See the video below for an example. |
| 102 | + |
| 103 | +.. youtube:: w9hTOJ7iJpE |
| 104 | + :divid: mooc_nested-write-code-video-ex |
| 105 | + :optional: |
| 106 | + :width: 1020 |
| 107 | + :height: 826 |
| 108 | + :align: center |
| 109 | + |
| 110 | +Finish writing the code for the following problem. |
| 111 | + |
| 112 | +.. activecode:: intro-sample-write-code-triple-mooc_nested |
| 113 | + :practice: T |
| 114 | + :autograde: unittest |
| 115 | + |
| 116 | + Write a function called ``triple(num)`` that takes a number ``num`` and |
| 117 | + returns the number times 3. For example, ``triple(2)`` should return 6 and |
| 118 | + ``triple(-1)`` should return -3. Look below the code to check for any |
| 119 | + compiler errors or the results |
| 120 | + from the test cases. Be sure to ``return`` the result. |
| 121 | + ~~~~ |
| 122 | + def triple(num): |
| 123 | + # write code here |
| 124 | + |
| 125 | + print(triple(2)) |
| 126 | + print(triple(-1)) |
| 127 | + |
| 128 | + ==== |
| 129 | + from unittest.gui import TestCaseGui |
| 130 | + class myTests(TestCaseGui): |
| 131 | + |
| 132 | + def testOne(self): |
| 133 | + self.assertEqual(triple(2),6,"triple(2)") |
| 134 | + self.assertEqual(triple(3),9,"triple(3)") |
| 135 | + self.assertEqual(triple(-1),-3,"triple(-1)") |
| 136 | + self.assertEqual(triple(0),0,"triple(0)") |
| 137 | + self.assertEqual(triple(11),33,"triple(11)") |
| 138 | + |
| 139 | + myTests().main() |
| 140 | + |
| 141 | +.. parsonsprob:: intro-sample-puzzle-mooc_nested |
| 142 | + :numbered: left |
| 143 | + :adaptive: |
| 144 | + :practice: T |
| 145 | + |
| 146 | + Write a function called ``triple(num)`` that takes a number ``num`` and |
| 147 | + returns the number times 3. For example, ``triple(2)`` should return 6 and |
| 148 | + ``triple(-1)`` should return -3. |
| 149 | + ----- |
| 150 | + def triple(num): |
| 151 | + ===== |
| 152 | + return num * 3 |
| 153 | + |
| 154 | + |
| 155 | +Solving Write Code Problems with an Adaptive Mixed-up Puzzle as Scaffolding |
| 156 | +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 157 | +If you see a problem like the one below, you will need to write code. You can go to the **toggle bar** above the problem description to open a mixed-up puzzle that will help you write the code. |
| 158 | +The mixed-up puzzle will have blocks of code that you can drag and drop to create a solution. You can also use the "Help me" button to get additional assistance if needed. |
| 159 | + |
| 160 | +.. selectquestion:: intro-sample-toggle-mooc_nested |
| 161 | + :fromid: intro-sample-write-code-triple-mooc_nested, intro-sample-puzzle-mooc_nested |
| 162 | + :toggle: lock |
| 163 | + |
| 164 | + |
| 165 | +What to do next |
| 166 | +=============== |
| 167 | + |
| 168 | +.. raw:: html |
| 169 | + |
| 170 | + <p>Click on the following link to take the pre survey and the skill assessment: <b><a id="pre_survey"> <font size="+1">Pre-survey</font></a></b></p> |
| 171 | + |
| 172 | +.. raw:: html |
| 173 | + |
| 174 | + <script type="text/javascript" > |
| 175 | +
|
| 176 | + window.onload = function() { |
| 177 | +
|
| 178 | + a = document.getElementById("pre_survey") |
| 179 | + a.href = "pre_survey.html" |
| 180 | + }; |
| 181 | +
|
| 182 | + </script> |
0 commit comments