Topics: Tuples and lists
Lecture Notes
Lecture 9: Lambda Functions, Tuples, and Lists
Readings
Ch 5.1–5.3
Finger Exercise Lecture 9
Implement the function that meets the specifications below:
def dot_product(tA, tB):
"""
tA: a tuple of numbers
tB: a tuple of numbers of the same length as tA
Assumes tA and tB are the same length.
Returns a tuple where the:
* first element is the length of one of the tuples
* second element is the sum of the pairwise products of tA and tB
"""
# Your code here
# Examples:
tA = (1, 2, 3)
tB = (4, 5, 6)
print(dot_product(tA, tB)) # prints (3,32)
6.100L Finger Exercises Lecture 9 Solutions
Problem Set 2
Recitation 4
Recitations were smaller sections that reviewed the previous lectures. Files contain recitation notes and worked examples in code.