Python For Real Flashcards

1
Q

parameter

A

a named variable that passes through a function’s argument(s)

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

module

A

a file that contains definitions—including variables and functions—that you can use once it is imported

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

generic import

A

Hint: It’s helpful to print the contents of a newly imported module you’re unfamiliar with to make sure you’re not reusing its content names.

simply calling a module in its entirety allowing access to all of its contents but forcing you to include the module name before each owned function (which may help by allowing you to write similarly named functions and variables)

import math
math.sqrt(#)

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

function import

A

calls a single function from a module freeing you from having to prefix each use of the function with the module name

from module import function

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

universal import

A

Hint: It’s common for professional developers to import only the functionality that is required, and not blindly import an entire module when there is no good reason to do so.

calling everything from a module and allowing you to call its contents without a module name prefix which can potentially cause the hazard of overlapping names if you write a similar function or variable yourself

from module import *

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

argument

A

the process(es) defined in a function such as multiplying the parameter(s) by 3 then returning the result

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

return

A

command to return values or to exit the method without returning a value

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

list

A

a datatype you can use to store a collection of different pieces of information as a sequence under a single variable name (the sequence starts at 0, not 1)

list_name = [item1, item2, item3, etc.]

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

index

A

address that identifies an individual item’s place on a list (starting with 0, not 1) allowing you access by including it’s identifier in brackets attached to and immediately following the list name

index_name[3]

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

slice

A

calls forth a section of a list or string beginning with the first included index item and ending with but not including the last index number written

index_name[3:9]

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

.index()

A

searches an index for the first instance of the parameters input and returns the numerical location

example.index(wanted)

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

.insert()

A

allows you to add an item to a list as well as its new specific index location if provided first in the parentheses subsequently shifting all other list items down the list in terms of index numbering (keep in mind that the number doesn’t have to be a digit, it can be the numerical content of another variable)

example.insert(#, new_item)

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

for loop

A

assigns to a variable (for variable) the value of a designated list (in list_name) whose contents will be used one at a time in the following code (:)

for variable in list_name:
code

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

.append()

A

adds a new variable to the end of your list

list_name.append(variable)

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

.sort()

A

alphabetizes the contents of your chosen list

list_name.sort()

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

dictionary

A

similar to a list whose contents can be called by using keys rather than index numbers (great for things phone books & login pages) and is distinguished by declaring its contents within curly brackets even though its information is still manipulated using standard brackets

dict_name = {"k1":v1, "k2":v2, etc}
dict_name["key_name"] = new_value
17
Q

key-value pair

A

components of a dictionary item starting with the string to identify the item, colon, then the contents inside curly brackets

dict_name = {“key”:contents of item}

18
Q

del

A

deletes the chosen item from a dictionary

del dict_name[“key_name”]

19
Q

.remove()

A

removes the first instance of the specified item from the list without returning anything using the actual contents in quotation marks rather than an index location

list_name.remove(“item”)

20
Q

.pop()

A

removes and returns the contents of the list item at the index number/identifier you provide in parentheses

list_name.pop(index)

21
Q

del()

A

removes the contents of a list at the index location provided without returning anything

del(list_name[index])

22
Q

range()

A

function which returns a list of numbers from start up to (but not including) stop, each time increasing by step (start defaults to 0 and step defaults to 1)

range(start_num, stop_num, step_num)

23
Q

.join()

A

function that returns a string of the list argument’s elements (a sequence of strings) separated by the string named in the prefix

separator.join(string_list)

24
Q

\

A

escape character: also allows you to continue a specific line of code on the next line

25
Q

break

A

a one-line statement that means “exit the current loop”