Extra Credit Assignment 1

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

CSEN 2304 Introduction to Computer Science

Spring 2024

Extra Credit Assignment 1

Due date: May 1

This is an extra credit assignment. It is not part of the required assignments for the course.

As was discussed in class, there are several useful methods and functions that operate on Python lists.
They perform operations that are frequently needed in the design of algorithms. Three of those operations
are finding the minimum value of a list, finding the maximum value of a list, and summing the numeric
values contained in a list. The functions to perform those operations are:

• min(a_list)
• max(a_list)
• sum(a_list)

Each of those functions accepts a Python list as a parameter, performs the corresponding operation, and
returns the appropriate result.

For this extra credit assignment you are to write three separate Python functions that perform the same
operation as the min( ), max( ), and sum( ) functions. In your solution for the assignment you should name
your version of the functions my_min( ), my_max( ), and my_sum( ). Your version of the functions should
also accept a Python list as a parameter (you can assume the parameter will be a list of integer values) and
return the same result as the min( ), max( ), and sum( ) functions. However, your versions of the functions
should not use the min( ), max( ), or sum( ) functions. Instead, you should use the concepts and techniques
that have been covered in class to create your own implementations that do not require the use of the min(
), max( ), or sum( ) functions.

Make sure to test your functions from the main program part of a Python file. Your program should print
results to show that your version of the functions work correctly. An easy way to show your functions work
correctly is to create a list of integers, print the list of integers, and then print the result of first invoking the
Python min( ), max( ), and sum( ) methods on the list, and then print the result of calling your
implementation of each of the methods my_min( ), my_max( ), and my_sum( ) on the same list.

Make sure to include appropriate comments in your source code to document your program. Those
comments should include headings at the start of your code with your name, K-number, and the date
submitted. Also remember to follow the standard Python coding conventions discussed in class. Submit
your solutions via the corresponding Blackboard system link for this extra credit assignment.

You might also like