COP1000C (Python) Final Review
What two methods can be used to return a copy of a string named s converted to all lowercase and all uppercase respectively?
s.lower() and s.upper()
What two Turtle methods affect the color of a Turtle drawing?
t.pencolor(r, g, b) and t.fillcolor(r, g, b)
When using the counting instructions method of measuring efficiency, what are the two classes of instructions you must distinguish between?
- Instructions that execute the same number of times regardless of the problem size - Instructions whose execution count varies with the problem size
What statement regarding the use of lists is accurate?
- It is a sequence of data values (items or elements) - Each item is ordered by position (specified by an index) - Enclosed in square brackets ([ ]) - Can be altered - Resembles a string (similar structure, same operators) but has different sets of methods than it
As a rule of thumb, when should you include an __eq__ method in a class?
- Not all objects are comparable using less or greater than, but any two objects can be compared for equality or inequality. - This method supports equality tests with any type of object.
What is the maximum number of distinct color values that can be displayed by the true color RGB system?
16,777,216 (or 256³)
How can you associate a keyboard event and an event-handling method with a widget?
By calling the bind method.
In a computer, what component is known as the "processor"?
CPU (Central Processing Unit)
The encryption method that replaces a character in a text with another character some given distance away in the alphabet from the original is known as what type of cipher?
Caesar Cipher
What two items are included in the class header of a class defined in Python?
Class name and parent class name
What statement regarding precedence of operators is accurate?
From highest to lowest: 1. ** 2. - 3. *, /, % 4. +, - 5. ==, !=, <, >, <=, >= 6. not 7. and 8. or 9. =
What is the process in which the Python virtual machine recycles its storage known as?
Garbage collection
What effect does the following print statement have? print("Hello" * 5)
HelloHelloHelloHelloHello
The assignment of roles and responsibilities to different actors in a program is known as what type of design?
Responsibility-driven design
After the creation of a thread, what makes a thread "ready"?
Running its start method
What two items must be given to the socket function in order to create a socket object?
Socket family and socket type
The gradual process of developing functions to solve each subproblem in a top-down design is known as what process?
Stepwise refinement
What statement accurately describes the use of a parameter in Python?
The name used in the function definition for an argument that is passed to the function when it's called.
What is the dominant term when evaluating the amount of work in an algorithm?
The term in a polynomial expression with the largest amount of n, the size of the problem.
What is a one-way selection statement in the context of Python?
Type of control statement that prevents a program from performing an action if the condition is false; called the "if statement".