From 2be134d5569ef81061897cb84efbaa2a2a9bd5b3 Mon Sep 17 00:00:00 2001 From: nkmtijhb025 Date: Fri, 17 Oct 2025 12:24:31 +0200 Subject: [PATCH 1/2] so far --- student_code.py | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/student_code.py b/student_code.py index d7fdfd0..d9551ea 100644 --- a/student_code.py +++ b/student_code.py @@ -1,5 +1,11 @@ """Learning Outcome: Functions""" def sum_of_squares(n: int): + if num <= 0: + raise ValueError("Number cannot be a negative integer") + sum = 0 + for num in range (1, n + 1): + sum += num * num + return sum """ Calculate the sum of the squares of all integers from 1 to n. @@ -12,9 +18,21 @@ def sum_of_squares(n: int): Raises: ValueError: If n is a negative integer. """ + pass def evaluate_performance(grades: list, min_pass: int): + min_pass = 75 + grades = [] + + for grade in grades: + if grade >= min_pass: + return "Pass" + else: + return "Fail" + + + """ Evaluate the performance based on a list of grades and a minimum passing grade. @@ -28,6 +46,11 @@ def evaluate_performance(grades: list, min_pass: int): pass def calculate_cumulative_performance(scores: dict): + average = sum[scores]/ len[scores] + + + + """ Calculate the cumulative performance based on student scores. @@ -66,6 +89,12 @@ def rank_students(students: list[tuple[str, int]]): """Learning Outcome: Basic Loops""" def even_numbers(n: int): + evens = [] + for num in range (1, n+1): + if num % 2 == 0: + evens.append(num) + return evens + """ Generate a list of even numbers from 1 to n. @@ -78,6 +107,11 @@ def even_numbers(n: int): pass def odd_numbers(n: int): + odds= [] + for num in range (1, n+1): + if num % 2 != 0: + odds.append(num) + return odds """ Generate a list of odd numbers from 1 to n. @@ -220,6 +254,7 @@ def transform_string(input: str, transform: str): pass def sum_and_average(nums: list[int]): + """ Calculate the sum and average of a list of numbers. @@ -232,6 +267,11 @@ def sum_and_average(nums: list[int]): pass def word_frequency_count(words: list[str]): + words = [] + word_count = 0 + + for w in words: + word_count += 1 """ Count the frequency of each word in a list. @@ -273,6 +313,7 @@ def find_median(nums: list[int]): pass def reverse_string(input: str): + return reverse_string[::-1] """ Reverse the given string. @@ -285,6 +326,8 @@ def reverse_string(input: str): pass def largest_number(nums: list[int]): + nums = [] + """ Find the largest number in a list. @@ -297,6 +340,11 @@ def largest_number(nums: list[int]): pass def is_prime(n: int): + for num in range(n): + if num // num == 1 and num // 1 == num: + return True + else: + return False """ Check if a number is prime. From 3ea6465de1599bb5f5e5e2a56a0c05642a481323 Mon Sep 17 00:00:00 2001 From: nkmtijhb025 Date: Fri, 17 Oct 2025 13:01:12 +0200 Subject: [PATCH 2/2] student_code.py --- .vscode/settings.json | 11 +++++++++++ student_code.py | 26 ++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..e9e6a80 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,11 @@ +{ + "python.testing.unittestArgs": [ + "-v", + "-s", + "./tests", + "-p", + "test_*.py" + ], + "python.testing.pytestEnabled": false, + "python.testing.unittestEnabled": true +} \ No newline at end of file diff --git a/student_code.py b/student_code.py index d9551ea..eb8235f 100644 --- a/student_code.py +++ b/student_code.py @@ -226,6 +226,11 @@ def skip_divisible_by_num(n: int, length: int): """Learning Outcome: Processing Data""" def square_numbers(nums: list): + nums = [] + squared = [] + for num in nums: + num = num * num + return squared.append(num) """ Calculate the square of each number in a list. @@ -238,6 +243,7 @@ def square_numbers(nums: list): pass def transform_string(input: str, transform: str): + """ Transform a string based on the specified transformation type. @@ -254,6 +260,9 @@ def transform_string(input: str, transform: str): pass def sum_and_average(nums: list[int]): + nums = [] + sum_and_average(nums) + return sum_and_average """ Calculate the sum and average of a list of numbers. @@ -284,6 +293,12 @@ def word_frequency_count(words: list[str]): pass def filter_even_numbers(nums: list[int]): + nums = [] + even_integers = [] + for num in nums: + if num % 2 == 0: + even_integers.append(num) + return even_integers """ Filter out even numbers from a list. @@ -298,6 +313,10 @@ def filter_even_numbers(nums: list[int]): """Learning Outcome: Simple Algorithms(Problem Solving)""" def find_median(nums: list[int]): + nums = [] + median = sum(nums) / 2 + return median + """ Find the median of a list of numbers. @@ -313,6 +332,7 @@ def find_median(nums: list[int]): pass def reverse_string(input: str): + return reverse_string[::-1] """ Reverse the given string. @@ -357,6 +377,12 @@ def is_prime(n: int): pass def count_character_occurrences(word_sentence: str, char_count: str): + word_sentence = "" + char_count = 0 + + for char in word_sentence: + char_count += 1 + return char_count """ Count the occurrences of a character in a given sentence.