Question: I have a data set with student names, their student ID, and the date they took an exam taken. It looks a bit like this:

| Student ID | Student Name | Date Taken |
| --- | --- | --- |
| 01 | Christian | 2009-09-24 |
| 01 | Christian | 2015-06-16 |
| 01 | Christian | 2014-05-14 |
| 12 | Laura | 2017-01-04 |
| 12 | Laura | 2009-05-12 |
| 43 | Alex | 2014-05-07 |
| 43 | Alex | 2009-05-01 |
| 43 | Alex | 2009-08-24 |
| 43 | Alex | 2013-04-29 |
| 06 | Sarah | 2018-05-03 |
| 06 | Sarah | 2015-06-24 |

I want to create a variable that accounts for the cumulative number of exams taken by each student, without counting the first exam they have taken (based on the date they took it).

I tried doing this by:

```
count(Student ID, "01")
count(Student ID, "02")

```

etc.

But I feel that this is not the most efficient way to do it and it also doesn't give me a good summary of the data by student name. I want to use student ID vs student name, because some names repeat, yet their student ID is different. I'm unsure how to go about this code, or if I am in the right track.

I was thinking as well of making an extra column where each exam value is counted as 1, and first projects launched as 0. And then adding the numbers per ID. But I am also unsure on how to go about the code.

Any suggestions? Thank you a million beforehand!

Answer: 
This would rather depend on what data types *a* and *b* are. If they are simple types (e.g., numeric) then:

```
if a > b:
  maximum, minimum = a, b
else:
  maximum, minimum = b, a

```

...might be faster than calling the min and max functions.

Or, if you like one-liners:

```
maximum, minimum = (a, b) if a > b else (b, a)

```
Mathematically `min(a,b)` is the same as `a+b-max(a,b)`. Whether this is an improvement is debatable.