### COMP203 Midterm Exam

Name:
Please write your answers in the space provided. You are allowed a textbook, calculator and notes but you are not allowed to use a computer, cell phone, or other device capable of communication.

If you get stuck on a problem, leave it blank and return to it later. You will receive partial credit for code with minor errors, but please check your work if you have time.

1. Write a procedure that accepts a number as input and then draws a hexagon whose side length equals that number.
2. Write a procedure that asks a person for their favorite musician and then uses the musican's last name in a sentence, as shown below. Punctuation counts!
```Who is your favorite musician?
K. D. Lang
Everybody loves Lang!
? musicianchat
Prince
Everybody loves Prince!
? musicianchat
John Lennon
Everybody loves Lennon!
```
3. Professor Burgiel wanted to draw a picture of a smiley face (below left).

When she ran her program, what she got was the picture above on the right. Find as many errors in the following two procedures as you can:
```to square :size
repeat 4 [forward 40 right 90]
end

to face
right 180 repeat 180 [forward 1 right 1] ; mouth
penup forward 50 pendown square 40       ; right eye
penup right 90 forward 80 square 40      ; left eye
penup left 90 forward 10 left 90 forward 20 pendown
square 20                                ; nose
end
```
4. Write a Logo operation that takes one input and outputs "false if the input is a list and "true otherwise.
5. Write a recursive procedure to keep asking the same question until the user gets the right answer.
```? keepquizzing
Who is the greatest musician of all time?
K. D. Lang
Who is the greatest musician of all time?
Michael Jackson
Who is the greatest musician of all time?
Billy Joel
Who is the greatest musician of all time?
John Lennon
Good job!
?
```

Bonus: (5 points) Use a for loop to print the sequence:
```2
4
8
16
32
64
```