Problem 1
---------
(a) not (10 >= 0) and (100/0)

False, bool

(b) long(3**2)/2.0 + 1/2

4.5 , float

(c) 4 <= int(math.sqrt(random.randint(20, 30)))

True, bool

(d) float(str(5\%2) + str(5/2))

12.0, float

(e) sys.maxint + 2 - 3

9223372036854775806L, long

(f) bool(0.0001) and ("hello" - "he")

error, subtraction operator is not defined on strings

(g) -3+-2**3*4%9---10%3

0, int

(h) random.random()*len(bin(9)) > 9

False, bool

(i) 5 + ** 8 - 22

error, ** needs two operands, one on each side

(j) (len("forty") + len("four"))%len("three")**2

9, int

Problem 2(a)
------------

1: 1
2: 1 2
3: 1
4: 1 2 3
5: 1 2 3
6: 1

Problem 2(b)
------------

ok bye
okbye byeok
okbyebye byeokok

Problem 2(c)
------------

33333
1133333
01133333

Problem 3(a)
------------
x = raw_input()
y = raw_input()
z = raw_input()

# Check if x is a shortest string

if (len(x) <= len(y)) and (len(x) <= len(z)):

    print x  

else:
    # Check if y is a shortest string

    if (len(y) <= len(z):

        print y
    else:
        print z

Problem 3(b)
------------
x = float(raw_input())

series = 0.0
nextTerm = 1.0
counter = 1

# keeping adding nextTerm to series as long as nextTerm is large 
# enough and we have not added 1000 terms

while (counter <= 1000) and (nextTerm > 0.0000001):

    series = series + nextTerm
 
    # Compute a new value for nextTerm from its previous value

    nextTerm = nextTerm*x/counter

    counter = counter + 1
    
print series

Problem 4
---------

prefixSum = 0 # a variable that keeps track of prefix sums
outputString = "" # a variable that keeps track of the output string

# repeat until a zero is read
while True:
    n = int(raw_input())
    if n == 0:
        break

    # update prefixSum and the outputString
    prefixSum = prefixSum + n
    output = output + str(prefixSum) + " "

print output
