Function Definition Flashcards Preview

Tiger Cards > Function Definition > Flashcards

Flashcards in Function Definition Deck (41)
Loading flashcards...
0

Will the following return a value?

aVar=type(8)
aVar

aVar=type(8)
aVar

Yes
class 'int'

1

Will the following return a value?

print(8)

No
print(8) is just an effect of displaying data on screen. It didn't produce anything new

2

Will the following return a value?

aVar=print(type(8))
aVar

aVar=print(type(8))
aVar

Yes because of the type(8)

3

Define stack diagram

Shows values of each variable and functions

4

Define frame

A box with names of functions/variable with the parameters, values, and/or variables inside it

5

Define traceback

It tell us where in our program contains an error

6

Define local variable

A variable that only exist within a function

7

Define function call/caller

A statement that calls a function

8

Define module

A file that contains a collection of related function and other definition

9

Define import statement

A statement that reads a module file and creates a module object

10

Define module object

A value created by an import statement that provides access to the values defined in a module

11

What will happen to the following?
a='app'
b='app'
a is b

True because of same object

12

What will happen to the following?

a=[1,2]
b=[1,2]
a is b

False because even though they are the same value, they are different list

13

What will happen to the following?

a=[1,2]
b=a
b is a

True

14

Define reference

Association of a variable with an object

Ex. a='t'
b=a
b is a
True

15

What will happen to the following?

a=[1,2]
b=a
b.append(3)
b

[1,2,3]

16

What will happen to the following?

a='cd'
b=a
b.append(f)
b

Error!

17

What will happen to the following?

t1=[1,2]
t2=t1.append(3)
t1

t2

t1
[1,2,3]

t2
None

18

What will happen to the following?

t1=[1,2,3]
t3=t1+[4]
t1

t3

t1
[1,2,3]

t3
[1,2,3,4]

19

Will the following work?
def repeat_lyrics():
print_lyrics()
def print_lyrics():
print('I'm an idiot')

repeat_lyrics()

Yes

20

Define stack frame

A chunk of memory

21

Fun fact: every time a function is called, a stack frame is created

Wow

22

Define scope of a variable

It refers to a section of a program where the variable is known

23

Define Global variable

Variable known over the entire program

24

What is the advantage of the following?

import turtle as t
import turtle as t1

You can create more than one turtle

25

What is the advantage of the following?

from math import sqrt, Pi

You can import what you need out of the chosen module

26

Define encapsulation

Taking a piece of code and turning it into a function

27

What are three advantages of encapsulation?

Reusable

Eliminates repetitive code

Attaches a name to the code which serves as a documentation

28

Define generalization

Makes a function or program more general

29

Define keyword argument

They are the name of the parameters in an argument list