posted Apr 4, 2017, 7:26 AM by Samuel Konstantinovich   [ updated Apr 4, 2017, 7:31 AM ]
Small Group activity: 
New seats for today! 
1st, 3rd, and 5th student in each row, swap with the person in FRONT of you (They are behind your computer)

Common issues:

The value of the expression 
is:  "ab"  (with quotes)

The output of the statement:  
print "a"+"b" 
is:   ab    (without quotes)

print x    will print the value inside variable x.

print "x"  will print an x on the output. 

Classwork: You are collaborating on a fake quiz! You may use your reference sheet, but NOT the computer.
1. Work with 3-4 of your neighbors. 
2. Do not run the code! Do not run the code!
3. Agree with each other on the answers and EVERYONE write it down. (include the question)
4. After completing a section, compare that ENTIRE section with 2 neighboring groups.
5. Move on to the next section only after 2 other groups agree with you.

By the end of this everyone should have the same answers, and should be convinced that they are correct. 

EVALUATE EACH OF THESE: (The actual problems)
#I starting list and strings
s = "two fish?"
L = ["two","fish?"]
L2 = ["one","fish","two","fishs?"]

#II len
print "---LEN:---"
print len(s)
print len(L)
print len(L2)

#III indexing
print "---INDEX:---"
print s[1]
print L[1]
print L2[1]

#IV slicing
print "---SLICES:---"
print L2[1:3]
print L2[2:3]
print L2[:2]
print L2[::2]
print L2[1::2]

#V split
print "---SPLIT:---"
print "this is a test".split()
print "this is a test".split("s ")

#VI join
print "---JOIN:---"
print "wh".join(["o"," are"," you"])
print "an".join(["b","n","a"])

#VII split and join
print "---SPLIT+JOIN:---"
print "!".join("the only way to go?".split())
print "".join("bannana".split("an"))


#New Python Stuff (not on quiz yet)
print "---range:---"
print range(5)
print range(2,5)
print range(2,10,2)
print "---in:---"
print "a" in "fish"
print "i" in "fish"
print 5 in [1,2,3]
print 5 in [3,4,5]