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