[フレーム]

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 3

  1. String Manipulations

    What does the code below print?

    s = "6.00 is 6.0001 and 6.0002"
    new_str = ""
    new_str += s[-1]
    new_str += s[0]
    new_str += s[4::30] 
    new_str += s[13:10:-1]
    print(new_str)
    

  2. For Loops with Strings

    How many times will the code below print “common letter”?

    s1 = "mit u rock"
    s2 = "i rule mit"
    if len(s1) == len(s2):
     for char1 in s1:
     for char2 in s2:
     if char1 == char2:
     print("common letter")
     break
    

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 によって変換されたページ (->オリジナル) /