Skip to content

SE Bang!

banner

Setup

  • Each player secretly draws one role card.
  • Your role defines your hidden goal — keep it secret until the end (you will be punished if you revealed it too early).

Goal

Work together to improve a small Python function the tutor show to you. Everyone edits the same code, you should work together on the same file on the same computer.

Silence Rule

  • You must not reveal or hint at your role.
  • Base your arguments only on reasoning about the code.
  • Keep the discussion respectful and focused.

Time

You have 5 minutes to discuss and edit the code together.

Reveal

When the tutor asks, everyone reveals their role. Check which goals were met and who managed to stay hidden.

Scoring

  • +1 point for each goal successfully met (over 50% of objectives achieved).
  • 0 points for unmet goals.
  • −1 point for each role correctly identified before the reveal.

Debrief

Reflect briefly:

  • Which goals aligned or conflicted?
  • How did hidden intentions shape the teamwork?
  • What helped or hindered collaboration?

Code snippets to work on

1: Factorial

A simple recursive function to compute the factorial of a non‑negative integer. It lacks input validation and does not handle negative values gracefully.

1
2
3
4
def factorial(num):
    if num == 0:
        return 1
    return num * factorial(num - 1)

2: Average

Calculates the average of numeric values in a list by summing and dividing by the count. It does not handle empty lists or mixed types properly, and it may produce integer division depending on the Python version.

1
2
3
4
5
def average(nums):
    total = 0
    for n in nums:
        total += n
    return total / len(nums)

3: Parse Date

Splits a date string formatted as "YYYY-MM-DD" into integers for year, month, and day. It assumes the input is valid, without checking ranges or supporting other separators.

1
2
3
4
5
6
def parse_date(date_str):
    parts = date_str.split('-')
    year = int(parts[0])
    month = int(parts[1])
    day = int(parts[2])
    return (year, month, day)

4: nth Prime

Finds the nth prime number by iterating through candidates and testing divisibility. It is inefficient and does not check for non-positive inputs or optimize prime detection.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
def nth_prime(n):
    count = 0
    candidate = 2
    while True:
        is_prime = True
        for i in range(2, candidate):
            if candidate % i == 0:
                is_prime = False
                break
        if is_prime:
            count += 1
            if count == n:
                return candidate
        candidate += 1

5: Celsius to Fahrenheit

Converts a Celsius temperature to Fahrenheit using the standard formula. It lacks input validation and does not provide rounding or handle lists of temperatures.

1
2
def c_to_f(temp):
    return temp * 9 / 5 + 32

6: Sort Strings

Sorts a list of strings alphabetically using a nested loop swap. It compares strings case‑sensitively and mutates the input list directly.

1
2
3
4
5
6
7
8
def sort_strings(strings):
    for i in range(len(strings)):
        for j in range(i + 1, len(strings)):
            if strings[i] > strings[j]:
                temp = strings[i]
                strings[i] = strings[j]
                strings[j] = temp
    return strings

7: Count Words

Counts the number of non‑empty substrings in a string separated by spaces. It treats punctuation as part of words and does not handle other whitespace or edge cases.

1
2
3
def count_words(s):
    words = s.split(' ')
    return len([w for w in words if w])

8: Max Value

Returns the largest value in a list by iterating and updating a maximum variable starting at zero. It fails for lists containing only negative numbers or when the list is empty.

1
2
3
4
5
6
def max_value(lst):
    current_max = 0
    for v in lst:
        if v > current_max:
            current_max = v
    return current_max

9: Fibonacci

Recursively calculates the nth Fibonacci number. The base cases cover n <= 1, but the function does not validate input or handle negative values, and its recursion is inefficient.

1
2
3
4
def fibonacci(n):
    if n <= 1:
        return n
    return fibonacci(n - 1) + fibonacci(n - 2)

10: Palindrome

Checks if a string reads the same forwards and backwards using slicing. It is case‑sensitive and includes all characters, ignoring spacing or punctuation.

1
2
def is_palindrome(text):
    return text == text[::-1]

11: Area

Computes the area of a rectangle given length and width when the shape parameter is "rectangle". For any other shape, it returns None without error handling.

1
2
3
4
5
def area(shape, a, b):
    if shape == 'rectangle':
        return a * b
    else:
        return None

12: Remove Duplicates

Creates a new list by iterating through the original list and appending items not already present. It uses nested loops and does not preserve order efficiently for large lists.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
def remove_duplicates(l):
    result = []
    for x in l:
        found = False
        for y in result:
            if x == y:
                found = True
                break
        if not found:
            result.append(x)
    return result

13: Dict to JSON

Manually concatenates a dictionary into a JSON‑like string with key–value pairs separated by commas. It does not handle strings appropriately and cannot serialize nested structures.

1
2
3
4
5
def dict_to_json(data):
    items = []
    for key, value in data.items():
        items.append('"{}": {}'.format(key, value))
    return '{' + ', '.join(items) + '}'

14: BMI

Calculates Body Mass Index (BMI) from weight in kilograms and height in centimeters. The default height is fixed, and the function does not check for invalid or missing inputs.

1
2
3
def bmi(weight_kg, height_cm=170):
    height_m = height_cm / 100
    return weight_kg / (height_m ** 2)

15: Read File

Opens a file, reads its entire content, prints it, and returns it. It does not close the file or handle exceptions for missing or large files.

1
2
3
4
5
def read_file(path):
    f = open(path, 'r')
    content = f.read()
    print(content)
    return content