0% found this document useful (0 votes)
25 views

Extra Credit Assignment 1

The document describes functions to find the minimum, maximum, and sum of numbers in a list in Python. It defines functions called my_min, my_max, and my_sum that take in a list and return the minimum number, maximum number, and total sum respectively. It provides a test case using a sample list to demonstrate the functions.

Uploaded by

engrkumailabbas
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views

Extra Credit Assignment 1

The document describes functions to find the minimum, maximum, and sum of numbers in a list in Python. It defines functions called my_min, my_max, and my_sum that take in a list and return the minimum number, maximum number, and total sum respectively. It provides a test case using a sample list to demonstrate the functions.

Uploaded by

engrkumailabbas
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

CSEN 2304 Introduction to Computer Science

Extra Credit Assignment 1

Code:

# Function for finding minimum number of a list

def my_min(lst):

if not lst:

return None

minimum = lst[0]

for num in lst:

if num < minimum:

minimum = num

return minimum

# Function for finding maximum number of a list

def my_max(lst):

if not lst:

return None

maximum = lst[0]

for num in lst:

if num > maximum:

maximum = num

return maximum

# Function for summing numeric values in a list

def my_sum(lst):

total = 0

for num in lst:

total += num

return total

test_list = [40, 20, -2, 2, 66, -1, 5]

print("Minimum value of list:", my_min(test_list))


for num in lst:

total += num

return total

test_list = [40, 20, -2, 2, 66, -1, 5]

print("Minimum value of list:", my_min(test_list))

print("Maximum value of list:", my_max(test_list))

print("Sum of numeric values in list:", my_sum(test_list))

Output:

You might also like