Intro to Functions: Continued Flashcards

1
Q

Variable

A

A variable is a name that references a value, or piece of data, stored in computer memory. We can assign values to variables, and read values from variables.

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

Variable Declaration

A

The line of code where we first introduce a variable, usually the first place where we give a variable a name and a value

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

Scope

A

The area of a program where a given variable can be accessed or used

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

Local Variable

A

A kind of variable that has the smallest scope: local scope. The most common kind of variable.

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

Function

A

Lines of code (1 or more) that are related, grouped together, and named. Once defined, these lines of code are reusable and can be called over and over again.

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

Global Variable

A

A kind of variable that has the largest scope: global scope.

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

Debugging Variable Scope: NameError

A

When we try to access a variable that is not in scope, the Python interpreter raises a runtime error NameError for that variable.

Observe and run this code that attempts to access my_undefined_fruit even though my_undefined_fruit is not defined within this code.

No definition of my_undefined_fruit found here!

print(f”An {my_undefined_fruit} a day keeps the doctor away?”)

Our error message gives us a clue that the variable my_undefined_fruit isn’t defined within this scope. Therefore, we got an error for accessing a variable not in scope.

NameError: name ‘my_undefined_fruit’ is not defined

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

How does a variable’s scope get determined? What are the rules that say what a variable’s scope is?

A

Variable scope is determined by:

(1) The kind of variable that’s defined
(2) The location (line of code) where the variable is defined

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

Documentation (aka docs)

A

Any written text, illustrations or video that describe a software or program to its users

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

Source code

A

The original code that creates a program, usually the human-readable version

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

API

A

A set of rules and tools that allows software to communicate with other software. Specifically designed to allow access to a wide audience.

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

Documentation Varies

A

When comparing the documentation between the pandas library API and the Slack API . We see that they’re dramatically different in a lot of ways:

how they look
the literal words
how the words are structured
how to navigate the page
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Object Identity

A

An object’s unique identity that never changes once it’s been created. Usually a number. Similar to an object’s address in memory. Find this with id(obj). In a comparison that uses is, Python compares object IDs.

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