CS256
Chris Pollett
Sep 13, 2017
Suppose we want to learn an `n`-bit nested boolean formula so that at least `1- 1/1000` of the time, the error rate was at most `1/(n+1)`. How many examples would the proof of the previous theorem suggest one should look at? Be specific on the value of `k` (look at our earlier proofs). Also, for what size `n` does this really make sense?
Post your solution to the Sep 13 In-Class Exercise Thread.
>>>2 / 3 + 7.9outputs 7.9; whereas, 2.0/3 + 7.9 outputs 8.566666666666666.
#!/usr/bin/env python # The above would mean don't have to type python when run under *nix # Comments begin with # print "Hello World"If we didn't have the first line or on Windows we would need to type "python hello.py" to run the program.
x = 7 x += 1 #note there are no ++ and -- operators x *= 3 y = 5 z = x - y print zwhich would print 19
print "%3d %0.2f" % (10, .9799)prints 10 with a leading space followed by 0.98
a = 5 if a > 4: print "a is bigger than 4" b = 99 if b < 50: print "b is too little" else: print "b is big enough" if a > 4 and b < 50: print "1" elif not a == 6: print "2" else: print "3"
f = open("hello.py") line = f.readline() while line: print line, #comma omits print's newline char #print (line, end='') #in python 3 line = f.readline() f.close()
for line in open("hello.py"): print line,to achieve the same affect
f = open("somefile.txt", "w") print >>f, "%02f" %0.7999 f.write("hello") f.close()
import sys print "\n".join(sys.argv) # print the command line arguments, each on their own line sys.stdout.write("Type something"); name = sys.stdin.readline()