Midterm Details

Midterm locations: All Midterm examinations take place at Karlovo namesti, room KN:E-220A, in building E, from Tuesday 2.4. to Monday 7.4.

Registration: Register yourself for a particular Midterm date and time: Timetable and registration sheet

Midterm is a 20-30 minutes individual discussion with the lecturer. The student is presented with one or more simple data manipulation task and should suggest a python solution to the task. Midterm is a closed-book examination, no additional sources including printed and electronic may be used.
Passing Midterm (with gain of at least 10 pts out of maximum 20 pts) is a mandatory part of the course.

The goal of Midterm is to show the ability to process basic programming tasks. In particular, student has to

  1. construct correctly a function with some parameters and call it from elsewhere in a code,

  2. apply loops, lists, strings, list comprehension to construct the solution.

Use of other concepts (recursion, lambda function) or data structures (sets, dictionaries ) is not mandatory. All problems are expected to be solved without any imported module or library (numpy, itertools, etc.). The time effectivity of the code is not an issue at Midterm and it is not graded.

The student is issued one programming problem, prepares the solution code on a sheet of paper and then discusses it with the examiner. Frequent part of the discussion is is to determine what would be the output of the code for some particular kind of data, like e.g. all items equal, some items equal to zero or empty string, etc. depending on the character of the problem.

The problems issued at Midterm are chosen in such way that they should not be challenging compared to the expected competence of a PGE student. If you are not sure, whether your programming level is sufficient, use the example problems below for a simple self-check. If you experience any significant trouble with a solution, or need a colleague or internet assistance, discuss the matter with the examiner in advance.


Grading follows approximately the examination scenario:

First, the student has to assemble the code of the solution, with possibly small input or hints from the examiner. This part is worth max 10 pts. Small typos, occasional missing commas/brackets/quotes etc., do not affect grading when their intended presence can be easily deduced from the context. For example, ListOfStrimgs = ['ab“, “cd fgh ijkl) is very probably meant to be ListOfStrings = ['ab', 'cd', 'fgh', 'ijkl']. On the other hand, exact values of list/arrays/string indexes and their placement in brackets and slices are often vitally important in the code, and this aspect of the solution does affect the grade.

Second, the code of the solution is checked by the examiner who would typically ask questions regarding some obvious data corner cases (E.g. “What if the parameter(s) of the function contain empty list/strings?”) or regarding the effects of additional minor changes in the code (E.g. “Can we swap these two lines of code? Or can we omit the following one? Will it affect the result?”). The goal of this part of Midterm is to demonstrate basic ability to analyze and predict code behaviour for different possible inputs. Satisfactory performance in this part is also worth max 10 pts.

The final total of points gained is then decided by the examiner.

If you are unsure about the possible Midterm outcome, use the presented examples as a simple self check. Midterm is going to be just a solution of another problem of similar kind.

Midterm problem examples

Write a function in Python and also write a piece of
code which will create example data for the function,
call the function, and write its result.
The example should contain at least 8 items.
Sometimes a code may use list comprehension,
and sometimes it can be written completely without it.
If possible, create two variants of your code:
With and without list comprehension.
The function takes one parameter - integer N
and returns a list of integers.
The contents of the returned list is
    [ 0, 1, 0, 2, 0, 3, 0, 4, ... , 0, N ].
The function takes one parameter - integer N
and returns a list of Strings.
The contents of the returned list is
    [ 'a', 'aa', 'aaa', 'aaaa', ...  ],
the length of the last string in the list is N.
The function takes one parameters L which is a list of integers.
The function returns the number of those items in L which
value is neither the minimum nor the maximum value of L.
The function takes two parameters A and B which are lists of integers.
The function returns the number of those items which appear in both lists A and B,
but never occupy the same position in A and in B.
The function takes one parameters L which is a list of strings.
The function returns a list of those strings in L
which  do not share any character with the first string in L.
Example: L = ['ab', 'bc', 'cd', 'ac', 'ad', 'ef'], returns ['cd', 'ef'].

courses/be5b33pge/practices/midtermexamples.txt · Last modified: 2024/03/20 04:42 by berezovs