8. [15 marks]

a) Write a Python program to print the integers (whole numbers) from 10 to 20, inclusive, using a loop.

Sample solution:

	for i in range(10,21):
	    print i

b) Write a Python program to prompt the user for their name and then say "hello" using their name (e.g. "Hello, Alan").

Sample solution:

	print "What is your name?"
	name = raw_input()
	print "Hello,", name

c) What does the following Python program output?

        x = 3
        y = x + x
        y = y + y
        y = x + y
        print y

Solution:

15

d) What does the following Python program output?

        x = 2
        while x < 30:
            x = x * 5
        print x

Solution:

50

e) What does the following Python program output?

        for i in range(2,5):
            print 'z' * i

Solution:

zz
zzz
zzzz

(press 'back' in your web browser to get back to where you were in the exam)