Skip to content

Commit ba43d14

Browse files
committed
added more options to make it harder
1 parent 964581e commit ba43d14

1 file changed

Lines changed: 23 additions & 1 deletion

File tree

source/ch3_javadatatypes.ptx

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -734,25 +734,47 @@ public class Histo {
734734
<exercise label="matching-python-java-loops">
735735
<statement>
736736
<p>
737-
Match each Python <c>for</c> loop with its equivalent Java <c>for</c> loop.
737+
Match each Python <c>for</c> loop with its equivalent Java <c>for</c> loop.
738+
Note: There are extra options that represent common syntax mistakes or off-by-one errors.
738739
</p>
739740
</statement>
741+
740742
<matches>
743+
741744
<match>
742745
<premise><c>for i in range(2, 101, 2)</c></premise>
743746
<response><c>for (int i = 2; i &lt; 101; i += 2)</c></response>
744747
</match>
748+
745749
<match>
746750
<premise><c>for i in range(1, 100)</c></premise>
747751
<response><c>for (int i = 1; i &lt; 100; i++)</c></response>
748752
</match>
753+
754+
<match>
755+
<response><c>for (int i = 1; i &lt;= 100; i++)</c></response>
756+
</match>
757+
749758
<match>
750759
<premise><c>for i in range(100, 0, -1)</c></premise>
751760
<response><c>for (int i = 100; i &gt; 0; i--)</c></response>
752761
</match>
762+
753763
<match>
764+
<response><c>for (int i = 2; i &lt;= 101; i += 2)</c></response>
765+
</match>
766+
767+
<match>
754768
<premise><c>for x, y in zip(range(10), range(0, 20, 2))</c></premise>
755769
<response><c>for (int x = 0, y = 0; x &lt; 10; x++, y += 2)</c></response>
770+
</match>
771+
772+
<match>
773+
<response><c>for (int i = 100; i &lt; 0; i--)</c></response>
774+
</match>
775+
776+
<match>
777+
<response><c>for (int x = 0, int y = 0; x &lt; 10; x++, y += 2)</c></response>
756778
</match>
757779
</matches>
758780
</exercise>

0 commit comments

Comments
 (0)