**Sample exam. **

It will cover chapters 1, 2, 3 and 4.

**1.** (25 points.) Write a program that reads a digit from the keyboard
using **input()**. Thus you should read the digit as a character. Convert
the digit to the letter of the alphabet whose position is given by the digit
and prints the letter, where 0 corresponds to the letter 'a'. Thus if the input
is 2, the output will be ** c**. Hint: use the **chr()**
and **ord()** functions.

** 2.** (25 points.) Write a program that gives you the character for a
given ASCII code read as input. Thus an input of 48 would give you **
'0'**. Hint: Use the **chr()** function .

** 3.** (10 points) In the following, state the type and value of each of
the following expressions. If the expression contains an error, write *
invalid* as the type and omit the value.

EXPRESSION TYPE VALUE
200 // 60 __________ __________
2 * 1 * 3 % 5 // 2 - 5 % 3 __________ __________
(5 + 4.0) / 3 * 2 + 5 / 5 __________ __________

**4.** (5 points) Given

silly

Which of the following causes a number to be placed in the location
** silly**. (circle the answers)

a) print( silly )
b) silly = int(input("Type your number"))
c) print ( "silly" )
d) "silly" = input("Type your number")
e) silly = int("123")

** 5.** (5 points) Given the following that sums the integers from
one to ten:

sum =_______
for j in range( ____, ___):
________ = sum + ______

Fill in the blanks so that no errors occur.

** 6.** (15 points) How many times would the **for** loops beginning
with the following statements be executed? If there is a compilation error,
type INVALID

_____ a. for j in range(6, 10, 2 ):
_____ b. for j in range(10, 7, 1):
_____ c. for j in range(10, 7, -1):
_____ d. for ch in range('1', 7):
_____ e. for j in range(-3, 1):