[フレーム]

Course Info

Topics
Learning Resource Types
Problem Sets
Lecture Notes
Lecture Videos
Programming Assignments with Examples

Download Course
In-Class Questions and Video Solutions

Lecture 4

  1. Function Calls

    How many total lines of output will show up if you run the code below?

    def add(x, y):
     return x+y
    def mult(x, y):
     print(x*y)
    add(1,2)
    print(add(2,3))
    mult(3,4)
    print(mult(4,5))
    

  2. Functions as Arguments

    What does the code below print?

    def sq(func, x):
     y = x**2
     return func(y)
    def f(x):
     return x**2
    calc = sq(f, 2)
    print(calc)
    

Course Info

Learning Resource Types
Problem Sets
Lecture Notes
Lecture Videos
Programming Assignments with Examples

MIT Open Learning
Over 2,500 courses & materials
Freely sharing knowledge with learners and educators around the world. Learn more
© 2001–2025 Massachusetts Institute of Technology
Proud member of: Open Education Global
© 2001–2025 Massachusetts Institute of Technology

AltStyle によって変換されたページ (->オリジナル) /