CS1 1st Quarter Exam

From WLCS

Directions: There are 3 parts to the exam.

  • Part I: Closed-book scantron - Do NOT write on the exam, only write on the scantron
  • Part II: Closed-book paper - You will write on this part
  • Part III: Open-book - answer the following questions on the computer and print out your answers


Directions: This portion of the exam is open-book, open-note, and CLOSED-person. You may use and test your code in Python. Copy and paste your answer in the spaces below. Be sure to put your name on your answer sheet.


17. Write an if statement that will check if a variable x is divisible by 18. If it is divisible by 18, then print a message that says x "is divisible by 18" and if it is not, then print out a message that says that it is not. (3 marks)

### Insert your answer to number 17 here ###

18. Write the function definition for a function named rectangleArea(height, width) that takes two parameters: height and width. The function should print the area of the rectangle. (4 marks)

### Insert your answer to number 18 here ###

19. (6 marks) Write a program that will do the following:

  1. Prompt the user to input a number between 0 and 3 (inclusive).
  2. Check if the user inputs a number less than 0, and if they do, then print "Your number is negative!".
  3. Check if the user inputs a 1, and if they do, then print out "Go Generals!"
  4. Check if the user inputs a 2, and if they do, then print out "Beat Yorktown!"
  5. Check if the user inputs a 3, and if they do, then print out "Washington-Lee r0x0rs!"
  6. If they input a number greater than 3, then print out "Your number is too high!"

### Insert your answer to number 19 here ###