Comp Sci Final

0.0(0)
studied byStudied by 0 people
0.0(0)
full-widthCall with Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/65

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No study sessions yet.

66 Terms

1
New cards

Python Data Structures

-built in non primitive structures: list, tuple, set, dictionary

-used to store and organize collections of data

-choice dpeends on mutabilty, order, and uniqueness

2
New cards

Lists

-ordered, mutable, allows duplicates

-can store mixed data type and nested lists

3
New cards

List concepts

-indexing (positvie and negative)

-slicing creates a new list

-slice assignment modifies a list in place

-lists are passed by refernece to functions

4
New cards

List common methods

-append(0, extend(), insert()

-pop(), remove(), clear()

-sort(), reverse()

5
New cards

Aliasing

  • b=a both refernce the same list

-changes to one affect the other

-use slicing ( a[ :] ) to copy safely

6
New cards

Tuples

-ordered and immutable

-allow duplicates

-faster and more memory-efficient than lists

7
New cards

Tuple Rules

-single element tuple needs a comma: (5, )

-cannot add/remoce elements (immutable)

-can modify mutiable elements inside a tuple

8
New cards

Tuple Operatiosn

-concatenation + and repetition *

-tuple unpacking: a, b = b, a

-sorted() returns a list, NOT a tuple

9
New cards

Sets

-unordered

-no duplicates

-no indexing

10
New cards

Sets Operations

-add(), update()

-remove()

-discard()

11
New cards

Set math

union, interaction, difference

12
New cards

Set use cases

remove duplicates, membership testing, mathematical set operations

13
New cards

File Handling Open methods

“r” read

“w” write (overwrite)

“a” append

“r+”, “w+”, “a+”

“b” binary, “t” text (default)

<p>“r” read</p><p>“w” write (overwrite)</p><p>“a” append</p><p>“r+”, “w+”, “a+”</p><p>“b” binary, “t” text (default)</p>
14
New cards

Reading & Writing

-read(), readline(), deadlines()

-write(), writelines()

-ALWAYS include \n for new lines

15
New cards

JSON Serialization

-convert python objects to string

-used heavily with APIs

16
New cards

json.dumps()

serialize

17
New cards

json.loads()

deserialize

18
New cards

Serialization

converting python object (like dictionary or list) into a JSON-formatted string

19
New cards

APIs

requests library

<p>requests library</p>
20
New cards

Status codes

200 OK, 400 Bad request, 401 Unauthorized, 403 Forbidden, 404 Not found, 503 Service unavailable

21
New cards

Returned Data

-usually dictionaries

-access via keys

22
New cards

Core OOP Concepts

-class: blueprint

-object: instance

-attributes: data

-methods: behavior

23
New cards

self.

refers to the object

24
New cards

instance attributes

belong to each object

25
New cards

class attributes

shared by all objects

26
New cards

encapsulation

-access data via methods (get or set)

-protect internal state

27
New cards

inheritance

-child class inherits from parent

<p>-child class inherits from parent</p>
28
New cards

overriding

child replaces parent method/attribute

29
New cards

super()

reuse parent methods

<p>reuse parent methods</p>
30
New cards

Inheritance types

-single

-multilevel

-multiple inheritiance

31
New cards

NumPy

-fast numerical arrays

-fixed size, same data type

32
New cards

NumPy Array creation

-np.array()

-np.zeros(), np.ones()

-np.arange(), np.linspace()

33
New cards

NumPy Indexing

similar ot lists

-multi-dimensional: a[row, col]

-boolean indexing is common on exams

34
New cards

NumPy Operations

-element-wise math

-statisitcal functions: mean, std, max, min

35
New cards

Pandas Series

-one dimensional labeled data

-like a column

36
New cards

Pandas Data Frame

-two dimensional table

-rows and columns

37
New cards

Pandas Indexing

df [ col ]

df.loc [ label ]

df.iloc [ index ]

-boolean filters

38
New cards

Visualization

-uses NumPy + Pandas data

-typically wiht matplotlib

-often paired with statiscal analysis

39
New cards

False

bool ( 0 ), ( 0, 0 ), ( “ “ ), ( None )

40
New cards

for loop

-iterates over knwon sequence

-ex: list, range, string

41
New cards

while loop

-runs until a condition change

-used when number of iterates is unknown

42
New cards

%

finds division remainder

43
New cards

//

integer divsion so must be whole number output

44
New cards

Why is range(5, 10, 0.5) incorrect

can NOT hvae float numbers in a range ONLY integers

45
New cards

continue

-skips remaining code in the loop

-immediately jumps to the next iteration

46
New cards

comments

-python ignores

-only exist for humans

47
New cards

and

need both to be True to return True

48
New cards

or

True if at least one operand is True

49
New cards

Natural Languages

change and evolve

50
New cards

Formal Language

strict fixed rules

51
New cards

==

equals

52
New cards

!=

not equal

53
New cards

case_:

-matches anything not previously matched

-acts like else

54
New cards

interpreter

-python executes code line by line

-no full compilation step

55
New cards

XOR operator (ex: 1011 ^ 0111)

same = 0

diff = 1

56
New cards

What happens if you hvae a return statment in a Python function with no value following

implicit return value is None

57
New cards

AND operator (ex: 110101 & 101010)

returns 1 if both 1

returns 0 if one is 0

58
New cards

pass

-placeholder

-does nothing

-prevents syntax erros for empty blocks

59
New cards
60
New cards

upper()

makes the string all uppercase

61
New cards

[::-1]

reverses

62
New cards

.find()

returns the starting index of the term

63
New cards

spilt()

spilts on any white space

-returns a list of words

64
New cards

iterations are more efficient

than recursion

65
New cards

s.clear()

removes all items from a set

66
New cards

pop()

removes the last element