CS21: Final Exam Study Guide

The final exam is cumulative.

In addition to the concepts below, you should know the concepts that were tested on all the quizzes in the course:

Historically, the final exam includes questions about each of the big ideas and skills in the course, such as:

Recent Topics and Practice Problems

Below are some of the new topics covered since the last quiz, as well as some additional practice problems.

You should be able to define and explain the following terms:

Things you are not responsible for:

While you will need to understand how objects work, you do not need to memorize the methods and objects for the Zelle graphics library

Practice problems:

  1. Write a complete program that plays a guessing game with numbers. The goal is for the user to guess a randomly selected number between 1 and 100 as quickly as possible. The program will inform the user whether the hidden number is higher or lower than the current guess. You must break the problem up into a main() function and at least one additional function.

The following is a sample run of the program:

I'm thinking of a number between 1 and 100.

Enter guess: 50
Number is higher than 50
Enter guess: pony
Invalid, try again: 588
Invalid, try again: 75
Number is lower than 75
Enter guess: 62
Number is lower than 62
Enter guess: 56
Correct!
You guessed it in 4 tries!
  1. Write a Student class that stores information for a Swarthmore student. The class should include the following instance variables:

Write the following methods for your Student class:

stu1 = Student(25,"Knerr")
stu1.registerCurrent(3)
stu1.withdraw()
stu1.passedCourse()
email = stu1.createEmail()
print(email)
print(stu1.toString())

Finally, write a main() method that tests the class. Each method should be tested at least once.

  1. Write recursive and iterative versions of a function that, given a string and a character, returns a new string with the character before and after each letter in the string. For example, calling the function with "hello" and "*" would return "*h*e*l*l*o*":
>>> insertChar("hello","*")
'*h*e*l*l*o*'
>>> insertChar("a",'+')
'+a+'
>>> insertChar("","-")
''
  1. Assume we have a word-count list, such as this:
wc = [['around', 99], ['beer', 300], ['bottle', 3], ['bottles', 297], ['buy', 1], ['down', 99]]

Write a function to take a word-count list and return the word that has the highest count. For example, if called on the list above, the function should return "beer".