6.100L | Fall 2022 | Undergraduate

Introduction to CS and Programming using Python

Lecture 8: Functions as Objects

Topics: Functions: environments, scope, functions as objects

Lecture Notes

Lecture 8: Functions as Objects

Lecture 8 Code


Ch 4.3–4.6

Finger Exercise Lecture 8

Implement the function that meets the specifications below:

def same_chars(s1, s2):
    s1 and s2 are strings
    Returns boolean True is a character in s1 is also in s2, and vice 
    versa. If a character only exists in one of s1 or s2, returns False.
    # Your code here

# Examples:
print(same_chars("abc", "cab"))     # prints True
print(same_chars("abccc", "caaab")) # prints True
print(same_chars("abcd", "cabaa"))  # prints False
print(same_chars("abcabc", "cabz")) # prints False

6.100L Finger Exercises Lecture 8 Solutions

Course Info

As Taught In
Fall 2022
Learning Resource Types
Lecture Videos
Lecture Notes
Problem Sets
Programming Assignments with Examples
Recitation Notes