Week 2 Flashcards

1
Q

How do you import a few items from a library?

A

from library import item, item, …

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How do you install new libraries?

A

With: pip install library
Or: python -m pip install library

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What does from library import * do?

A

It imports all public names from a module directly into the current namespace.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How should you format a print statement while debugging?

A

print(“DEBUG: …”)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What can RGB values range from?

A

0-255

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What are the three main aspects of coding?

A
  1. Thinking/planning
  2. Coding
  3. Debugging
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What are the three main aspects of coding?

A
  1. Thinking/planning
  2. Coding
  3. Debugging
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What are three aspects of thinking before you code?

A
  1. Read the entire specification
  2. Take notes (digitally/physically)

3.Think about how the program should work/interact (potential problems, missing knowledge)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Which order should you use ID & SR in your assignments?

A

Break down with SR, code with ID.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How are tuples written?

A
  1. tuple_name = (‘item1’, ‘item2’)
    Or
  2. tuple_name = ‘item1’, ‘item2’
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How do you write tuples with a single element?

A

With a comma after the first element

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What operations can be performed on tuples?

A

All operations that can be performed on lists that don’t change the lists.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What operations can be done on dictionaries?

A

len(), containment

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Does containment look at keys or values in dictionaries?

A

Keys

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What type of error will you get if you search for a key that is not in a dictionary?

A

A KeyError

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is a traceback error?

A

The code has not been written according to the rules of language or something has been used incorrectly

17
Q

What is a logic error?

A

It means your code does not produce the correct or expected output

18
Q

What does the list() function do?

A

Converts an iterable (tuple, set, list, etc.) into a list

19
Q

What does the tuple() function do?

A

Converts an iterable (list, set, string,etc.) into a tuple

20
Q

What does the sorted() function do?

A

It returns a new list containing all items from the iterable in ascending order without changing the original iterable

21
Q

What does the reversed() function do?

A

Returns an iterable that accesses the given sequence in reverse order

22
Q

What does the zip() function do?

A

Aggregates elements from two or more iterables into tuples, creating pairs of elements based on their positions

23
Q

What does the map() function do?

A

Applies a given function to each item of an iterable and returns a map object (an iterator) containing the results

24
Q

What does the filter() function do?

A

Creates an interator from elements of an iterable for which a function returns True

25
Q

How can you access items in a tuple?

A

With indexing (similar to lists):
tuple_name[#]

26
Q

How can you access items in a tuple?

A

With indexing (similar to lists):
tuple_name[#]

27
Q

What are frames?

A

Frames are a data structure that holds information about the execution state of a program

28
Q

What are tuples?

A

A tuple is an immutable, ordered built-in data type in Python used to store a collection of items

29
Q

What are containment operators?

A

They are used to check whether a value or an element exists within a container (“in”, “not in”)

30
Q

How do you bind a library name to something else?

A

import library as bind_name