CMPS-224 Lab 3 Functions and Lists in Python

Eddie Rangel
Department of Computer and Electrical Engineering and Computer Science
California State University, Bakersfield

Introduction

Goals: Understand how functions and lists work in Python 3.

Resources: Python 3 Documentation Documentation Python Lab 3 Materials

Files Needed:

Examine the following function header, then write a statement that calls the function, passing 12 as an argument.

    
        def show_value(quantity):
    
    

Look at the following function definition:

    
        def my_function(a, b, c): 
            d = (a + c) / b 
            print(d)
    
    

Write a statement that calls this function and uses keyword arguments to pass 2 into a, 4 into b, and 6 into c. What value will be displayed when the function call executes?

Write a function that accepts a list as an argument (assume the list contains integers) and returns the total of the values in the list.

    # Create a list.
    scores = [75, 80, 85, 90, 90.5, 100, 65, 70, 72, 88]
    

What to turn in

Show the programs running to me or our TA.