CS 1110 - Introduction to Programming

Review for Third Test

The following questions are provided to help you study for the third test. Do not expect to see these exact questions on the test.

  1. How are lists and strings alike? How are they different?

  2. For the loop that you wrote in problem 30, can you substitute the name of a string for the name of the list?

  3. What are two concatenation operators you can use with strings?

  4. Explain string slice notation using this example: string1[1:20:2].

  5. Write a few lines of code that will tell us what kind of characters are in a string, and what cases exist in it?

  6. If strings are immutable, how does the string method replace() work?

  7. What does the string method called split() do? How is that useful?

  8. Is this a list or a tuple? ['a', 'b', 'c']

  9. Okay, it was a list. What would it look like if it were a tuple?

  10. Since we can make both, what are the restrictions on tuples that do not apply to lists?

  11. How can you easily convert from a tuple to a list, or from a list to a tuple?

  12. What is the notation used when creating a dictionary? How is a dictionary different from a list?

  13. What would happen if you entered this code
    phonebook['Steve'] = '555-7738'

    a. if the dictionary did not exist?
    b. if the index indicated did not exist?
    c. if the index indicated does exist?

  14. How can we verify that an index exists in a dictionary?

  15. What is the command to remove an element from a dictionary? What is an element, anyway?

  16. What are two quick ways to remove all elements from a dictionary?

  17. What is true about a set that makes it a little like a dictionary?

  18. What is the result of the Union of two sets?

  19. When we ask for the difference between two sets, why does it matter which one we name first?

  20. What is the intersection of two sets?

  21. What module should be imported for a python program to be able to use its dump() and load() functions? What are they for?

  22. What is a class, with respect to writing python programs?

  23. Classes allow us to use encapsulation. Why is this helpful?

  24. What methods should we expect to find in a class that has two attributes?

  25. What method should we find in every properly constructed class?

  26. What is the difference between a class and an instande of it?

  27. In a UML diagram of a class, what do we expect to seen in the three separate parts of it?