comp 110 concepts

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/13

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

14 Terms

1
New cards

return statement required?

NO

functions do not need a return statement

2
New cards

where does a function go?

back to where it was called to see if there is more code to evaluate

3
New cards

return replaced with print?

a return statement cannot be replaced with a print statement

4
New cards

print after return

will raise an error because print references unreachable code

5
New cards

functions defined after reference in another?

if the main function is called after the other functions are defined, it is fine to enter because they are defined already

6
New cards

relative reassignment operator

only one =

not two ==: means that elements are equal to each other

7
New cards

changes are global

if a value is passed to a function and then modified, those changes are reflected globally

8
New cards

manipulation of object

the function does not copy the object

instead, it directly manipulates the original object

9
New cards

for loops

CANNOT print indexes

can print indexes with a while loop and for ... in range loop

be careful with variables - sometimes python will mess up with local and global variables

10
New cards

unit tests

do not forget the return type

11
New cards

modifying a key in a dict

update to the new key with the correct value

remove the old key with the pop method

12
New cards

init return

returns a reference number to the heap

doesn't take self as an argument but always has it as a parameter

self.attribute, SELF.ATTRIBUTE

13
New cards

methods in a class

when you define a method in a class, all objects of that class have that method associated with it

14
New cards

constructor calling

you don't have to have an instance of a class to call the class's constructor