3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 00:54:21) [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] Python Type "help", "copyright", "credits" or "license" for more information. # Another cool Python thing: ternary if # Ifs the old way: grade = 87 if grade >= 50: outcome = "pass" else: outcome = "fail" outcome 'pass' # We can to that in ONE line: outcome = "pass" if grade >= 50 else "fail" outcome 'pass' # This is a "functional programming" style of if statement. # In functional programming, everything is an expression. # You'll learn all about this in csc324. # When we evaluated tree.py, there were lots of doctest failures because # the contains function had doctest examples and no real body. I'm removing # those error messages here to avoid the clutter. [evaluate tree.py] Cannot read termcap database; using dumb terminal settings. 0 1 3 7 8 4 9 2 5 6 root left 1 2 3 right 1 2 3 # Building a tree "by hand" t1 = Tree(33) t1 Tree(33) t2 = Tree (1, [2, 3, 4]) t2 Tree(1, [2, 3, 4]) t3 = Tree(99, [t1, t2]) t3 Tree(99, [Tree(33), Tree(1, [2, 3, 4])])