@@ -581,7 +581,7 @@ Exercises
581581---------
582582
583583Obtain the `skeleton code for these exercises from GitHub classroom
584- <https://classroom.github.com/a/qTArFlxP > `__.
584+ <https://classroom.github.com/a/qTArFlxP> `__.
585585
586586.. proof :exercise ::
587587
@@ -654,12 +654,91 @@ people attend then I will also run a group Q & A session.
654654Practice questions
655655~~~~~~~~~~~~~~~~~~
656656
657- Some specifically-designed practice questions will be released at about the end
658- of term. In addition to this, there are a lot of very good exercises in
657+ Some specifically-designed practice questions are presented below. In addition to this, there are a lot of very good exercises in
659658chapters 7 and 9 of `Hans Petter Langtangen, A Primer on Scientific Programming
660659with Python <https://link.springer.com/book/10.1007%2F978-3-662-49887-3> `__.
661660You can access that book by logging in with your Imperial credentials.
662661
662+ The first two questions are in exam format.
663+
664+ .. proof :exercise ::
665+
666+ Obtain the `practice problem from GitHub Classroom
667+ <https://classroom.github.com/a/HdgipMxw> `__. Follow the instructions in
668+ the README file that will be displayed on GitHub on your copy of the page.
669+
670+ .. note ::
671+
672+ This exercise is fully set up as an exam question, including provisional
673+ points on the autotests. It should be doable in 30 minutes, though the
674+ level of programming is a little more basic than the exam questions.
675+
676+ .. proof :exercise ::
677+
678+ Obtain the `practice problem from GitHub Classroom
679+ <https://classroom.github.com/a/6usAsES4> `__. Follow the instructions in
680+ the README file that will be displayed on GitHub on your copy of the page.
681+
682+ .. note ::
683+
684+ This exercise is at the level of an exam question, though longer. An
685+ actual exam question would be pruned back to be achievable in 30
686+ minutes. Here the complete exercise is presented because the main thing
687+ you need to do is practice programming, and cutting out material
688+ doesn't help with that. Marks are not given as the question is the
689+ wrong length, so dividing 20 marks over the question would just be
690+ misleading
691+
692+ In addition to these exam-style questions, you can also usefully practice
693+ programming by going beyond the specification of the exercises in the course.
694+ The following exercises are just ideas for how to do that. They do not come
695+ with additional code or tests.
696+
697+ .. proof :exercise ::
698+
699+ Extend the :class: `Polynomial ` class from :numref: `Week %s <objects >` to
700+ support polynomial division. Polynomial division results in a quotient and
701+ a remainder, so you might choose to implement :meth: `~object.__floordiv__ `
702+ to return the quotient and :meth: `~object.__mod__ ` to return the remainder,
703+ in a manner analogous to integer division. You might also implement
704+ :meth: `~object.__truediv__ ` and have it return the quotient if the
705+ polynomial division is exact, but raise :class: `ValueError ` if there is a
706+ remainder.
707+
708+ .. hint ::
709+
710+ Don't forget that repeating code is poor style, so you might need a
711+ helper method to implement the actual polynomial division.
712+
713+ .. proof :exercise ::
714+
715+ Extend the :class: `Deque ` class from :numref: `Week %s
716+ <abstract_data_types>` to automatically resize the ring buffer by a
717+ proportion of its length when it is full, and when it becomes too empty.
718+ You can check the behaviour of your implementation against
719+ :class: `collections.deque `.
720+
721+ .. proof :exercise ::
722+
723+ For a real challenge, extend the groups implementation from :numref: `Week
724+ %s <inheritance>` to support taking the quotient of two groups. What do the
725+ values and validation of a quotient group look like in code? You could
726+ implement :meth: `~object.__truediv__ ` on :class: `Group ` to provide the user
727+ interface.
728+
729+ .. proof :exercise ::
730+
731+ Write additional single dispatch visitor functions to extend the
732+ capabilities of the symbolic algebra system you wrote in :numref: `Week %s
733+ <trees>`. You could, for example, write a visitor which performs
734+ cancellation of expressions involving 1 or 0. You could implement expansion
735+ of brackets according to distributive laws. Finally you could canonicalise
736+ commutative operators such as `+ ` and `* ` so that, for example `1 + x ` is
737+ mapped to `x + 1 `. Doing this over multiple layers of the tree
738+ (transforming `1 + 2*x + 3*x**2 ` to `3*x**2 + 2*x + 1 ` is an additional
739+ challenge.
740+
741+
663742.. rubric :: Footnotes
664743
665744.. [#python_in_python ] Most of the :ref: `Python Standard Library <library-index >` is written
0 commit comments