Functions Flashcards

(32 cards)

1
Q

bool()

A

a function which returns the Boolean value of a specified object

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

classmethod()

A

a function which converts a method into a class method

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

input()

A

a function which asks the user for text input

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

int()

A

a function which returns an integer object from any number or string

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

len()

A

a function which returns the number of characters

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

print()

A

a function which prints the specified message on screen

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

range()

A

a function which returns the sequence of numbers defined, incrementing by 1. Stops before a specified number and default is 0.

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

sum()

A

a function which returns the sum of values in an iterable

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

What is a function?

A

A function is a block of reusable, organised code, used to perform a set of specified instructions when called upon.

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

Why use a function?

A

Modularity, reusability, avoiding redundancy, readability

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

What kinds of functions are there?

A

Built-in, UDFs, anonymous/lambda

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

Method

A

A method is a function which is part of a class. It can be accessed with an instance or object of the class.

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

Parameter

A

Name used to define a function or method, listed inside of the function parenthesis

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

Argument

A

An argument is the value that are sent to the function when it is called

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

Default argument

A

An argument which can be defined within a function to be taken by default if no argument value is given during function call

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

Required argument

A

An argument which must be passed during function call in order

17
Q

Variable number of arguments

A

When a varying number of arguments can be given for a function, (*args) can be used

18
Q

Keyword arguments

A

Used to make sure arguments are given in the correct order, identify arguments using their parameter name

def plus(a, b)
      return a+b

plus(b=2, a=1)

19
Q

Global scope variable

A

A variable which is defined throughout the whole module (globally), as opposed to within a class

20
Q

Local scope variable

A

A variable which is defined within a class, outside of the class, the definition is not the same

21
Q

Arrays

A

A data structure that stores only values of the same datatype. Lists can store multiple datatypes.

22
Q

Module

A

A file containing python definitions and statements which can be imported into other modules.

23
Q

Function recursion

A

A function which calls on itself, directly or indirectly

24
Q

2-D array

A

An array with 1-D arrays as its elements. Often represents a matrix

arr = numpy.array([[1, 2, 3], [4, 5, 6]])

25
3-D array
An array with 2-D arrays as its elements. arr = numpy.array([[[1, 2], [3, 4]], [[5, 6], [7, 8]]])
26
OOP
A programming model that organises its software design around objects and data, rather than functions and logic. It operates on encapsulation, inheritance, abstraction, and polymorphism.
27
Encapsulation
Bundling data with methods that can operate on that data within a class. Hiding data within a class to prevent access or changing from anything outside of the class. Only through the classes methods can other objects interact with it.
28
Abstraction
Focuses on what an object must contain. Hides unnecessary details. Happens at design level
29
Inheritance
The ability for a derived class to inherit methods and variables from a base class. Allows classes to have relationships
30
Multiple inheritance
The ability for a derived class to inherit methods from two base classes or more
31
Multilevel inheritance
The ability for features to be inherited from another derived class. This can be of any depth
32
Polymorphism
The ability for a function or object of the same name to be used for a different purpose. A method defined in a class can be called the same name in a different class and used for a different purpose.