Week 2 Flashcards
How do you import a few items from a library?
from library import item, item, …
How do you install new libraries?
With: pip install library
Or: python -m pip install library
What does from library import * do?
It imports all public names from a module directly into the current namespace.
How should you format a print statement while debugging?
print(“DEBUG: …”)
What can RGB values range from?
0-255
What are the three main aspects of coding?
- Thinking/planning
- Coding
- Debugging
What are the three main aspects of coding?
- Thinking/planning
- Coding
- Debugging
What are three aspects of thinking before you code?
- Read the entire specification
- Take notes (digitally/physically)
3.Think about how the program should work/interact (potential problems, missing knowledge)
Which order should you use ID & SR in your assignments?
Break down with SR, code with ID.
How are tuples written?
- tuple_name = (‘item1’, ‘item2’)
Or - tuple_name = ‘item1’, ‘item2’
How do you write tuples with a single element?
With a comma after the first element
What operations can be performed on tuples?
All operations that can be performed on lists that don’t change the lists.
What operations can be done on dictionaries?
len(), containment
Does containment look at keys or values in dictionaries?
Keys
What type of error will you get if you search for a key that is not in a dictionary?
A KeyError