161-A1.0

From Microlab Classes
Jump to navigation Jump to search

Each programming exercise will have the following elements:

  • a problem specification,
  • a prescribed function name and argument list, and
  • some header script that will be included during testing.

All programming exercises can be submitted through a web app: https://submissions-adrianvidal.azurewebsites.net/ A password will be sent to students via their CRS email. Upon logging in, you will be asked to choose an exercise and to upload a file. Exercise 0 is an ungraded task that will quickly refresh some basic Python concepts and is intended for everyone to be familiar with the submission platform.

Unless otherwise specified, the following restrictions apply:

  • the submitted file should be at most 5 KB in size,
  • at most three submissions can be made in any eight-hour window.

The second restriction is enforced to encourage (1) spacing out submissions to think through the feedback received, and (2) better time management by using the waiting period for rest or for doing requirements from other subjects. For example, if the three most recent submissions are made at 8:00 am, 9:00 am, and 9:05 am, then the next submission can be submitted at 4:00 pm at the earliest (eight hours after 8:00 am).

Exercise 0: Frequency counting

In this task, you will simply write a function frequency_count that will take a string input_string of printable characters and return a dictionary object mapping each distinct character to the number of times it appears in the string argument. Your submission must be written as shown below:

def frequency_count(input_string):
    # Your code goes here..
    pass
}

For example, if the input string is 'CoE 161', then the output dictionary should be {'C':1, 'o':1, 'E':1, ' ':1, '1':2, '6':1}.

Besides the input argument, the submitted function should not take any user input, open any file, or print any output.

Submission grading

The header script for Exercise 0 is empty. That is, there will not be any predefined functions nor imported modules. A validator script will be run in the web app to only copy the function declaration with the prescribed name and argument list. As an example, consider a hypothetical submission below:

import random

test_global_var = 12345

def extra_function(args):
    # some code
    # ....

def frequency_count(input_string):
    # your code..
    local_var = list(input_string)
    # more code..

    return ans
}

def another_function(args):
    # some code
    # ....

During testing, the following Python script will run:

Python test script for execution
Header
# Header script will be inserted by the validator script in the app.
# Whenever available, this will be specified in the programming exercise.
Student submission (function only)
def frequency_count(input_string):
    # your code..
    local_var = list(input_string)
    # more code..

    return ans
}
Main test script
# Main test script goes here, and will not be visible to students.
# The script will test if the submitted code does the prescribed functionality.
# For successfully validated scripts, test results will be sent via email.

Please be careful not to call functions imported from libraries not specified in the header script. Doing that will cause the program to throw a NameError. Accessing global variables such as test_global_var in the example will similarly cause an error.

Do not include I/O commands such as input, print, or open. The validator script will return an error upon detecting usage of such functions.

Finished early?

We encourage everyone to manage their time wisely and keep in mind that there are other requirements to accomplish. While the web app provides some automation for providing quick feedback and scores, there are other activities that would still benefit from keeping us in the loop. By finishing early, we hope that you can engage with the more analytical and critical thought processes involved in written assessments, such as mathematical proofs or essays. If you get stuck at a certain error message, you may get in touch with your teacher and ask for some feedback beyond what the web app can provide.