15-110 Fall 2010 Quiz 2
10 Minutes

* No calculators, no notes, no books, no computers.
* Show your work.
  Correct answers without supporting calculations will not receive full credit.

1.       (25 pts) Write a function isTenMultiple that takes a positive integer value and returns true if the number is a multiple of 10 and false otherwise.

2.       (25 pts)  Trace the following code and show what it prints.

def mystery(m, p):
    y = m / p
    y = y * 100
    return y

 

print mystery(20, 30)

print mystery (30, 20.0)

3.       (25 points) Trace the following code and show what it prints.

x = 15 % 4

y = x - 5

x += 1

y -= 1

z = max(y/x, abs(x/y))

print x, "," , y , ",", z

 

4.       (25 pts – 5 pts each) What is the value and type of each of the following Python expressions?

·         4 ** 2

 

·         8 % 9

 

·         ‘ABC’ + str(3)

 

·         10 % 4 + 8 / 4

 

·         3.10 * 2

 

5.       Bonus/Optional (5 pts)
Write a function that given a positive integer value returns  the 100’s digit of that number.  If the number is less than 100, its 100's digit is 0.