Module 1 – Python Foundations Assessment#

Assessment Instructions#

This notebook is submitted for automated assessment.

Rules:

  • Do not rename required functions

  • Do not change function parameters

  • Ensure the notebook runs top-to-bottom without errors

Assessment is performed after submission using automated tests on the server.


Exercise 1 – Variables and Output#

Define:

  • name (string)

  • age (integer)

  • learning_python (boolean)

Print a formatted sentence including all three.

# YOUR CODE HERE

Exercise 2 – Lists, Loops, and Conditionals#

Create a list called numbers containing at least 5 numbers. Loop through it and print whether each number is even or odd. Also calculate the total of all numbers.

# YOUR CODE HERE

Exercise 3 – Functions#

Write a function with the exact signature:

def calculate_average(numbers):
    """returns average or None if empty"""
def calculate_average(numbers):
    # YOUR CODE HERE
    pass

Exercise 4 – Dictionaries#

Create a dictionary called student_scores mapping at least 3 student names to their scores. Print each student and score, then print the average score.

# YOUR CODE HERE

Exercise 5 – File Processing#

Write a function with the exact signature:

def analyse_file(filename):
    """returns (total_words, unique_words, longest_word)"""

The function should return a tuple of 3 values:

  1. total_words (int) – the total number of words in the file

  2. unique_words (int) – the count of unique/distinct words (e.g., if “apple” appears twice, count it once)

  3. longest_word (str) – the longest word in the file

Assume one word per line.

Example: A file containing apple, banana, apple, cherry should return (4, 3, 'banana')

def analyse_file(filename):
    # YOUR CODE HERE
    pass

Submission#

To submit your completed assessment:

  1. Save your notebook: File → Download → Download .ipynb

  2. Upload here: Submit Assessment