Study Guides (248,402)
CMPT 383 (3)
Forgot (1)
Final

# FinalPrep.pdf

3 Pages
129 Views

School
Department
Computing Science
Course
CMPT 383
Professor
Forgot
Semester
Fall

Description
Final review questions, CMPT 383 Fall 2010 Python code Consider the attached Python listing (on the last page). You are encouraged to run the examples to understand how they work. 1. Function example1 executes function doSomething() on every element in list container. Change the function to execute doSomething() on every element in container, assuming container is a Python set instead of a list. How are the two versions similar? How do they differ? What is the name for this property? 2. Consider function example2. What are the scopes of variables a, b, and c? Which values, if any, will persist after the function returns? 3. Consider the sequence of code Example 3. What is printed by the two print statements? Why? 4. Consider the sequence of code Example 4. Assume that list a and tuple b have the representations in memory I discussed in class. • Which variable should permit faster indexing (i.e., would a[750] or b[750] be faster or would they both be the same speed)? • How expensive would the conversion from list form to tuple form be? Would you want to do that in a tight loop? • What are the advantages of the internal representation for a list over the internal representation for a tuple? 5. Consider the sequence of code Example 5. At the point of the statement b = a, how many bindings exist for the name a? 6. Consider a (vastly simplified) mapping application that converts locations to business street addresses and vice versa. Assume locations are represented by a (latitude, longitude) tuple, with latitude and longitude each represented by a tuple of two numbers and an address is a string, such as “8888 University Drive”. • Create a dictionary that converts 49.279, 122.920 to “8888 University Drive” and 0,0 to “Santa's House”. • Write a for loop that prints every (location, address) pair in the dictionary • Write a routine that, given an address, returns its location in the above dictionary or (None, None) if the address is not in the dictionary. Python principles 1. Describe the difference between mutable and immutable types in Pytho
More Less

Related notes for CMPT 383
Me

OR

Join OneClass

Access over 10 million pages of study
documents for 1.3 million courses.

Join to view

OR

By registering, I agree to the Terms and Privacy Policies
Just a few more details

So we can recommend you notes for your school.