Lecture 4 flash cards

midterm/final studies

1
Q

what is a list ?

A

List [] is a collection which is ordered and changeable. Allows duplicate members

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

what is tuple?

A

Tuple () is a collection which is ordered and unchangeable. Allows duplicate members

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

what is set?

A

Set {} is a collection which is unordered and unindexed. No
duplicate members

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

what is dictionary ?

A

Dictionary {} is a collection which is unordered and changeable. No duplicate members.

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

are list mutable ?

A

yes

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

are tuples mutable ?

A

noooooooooooo

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

does each data type has it own method ?

A

yes

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

how to call a function in python

A

to call a function, use the function name followed by parenthesis

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

what are arguments ?

A

Arguments are specified after the function name inside the parentheses. You can add as many arguments as you want, just separate them with comma

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

how many types of arguments are there ?

A

4 types
default arguments
required arguments
keyword arguments
variable number of arguments

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

what is a default value ?

A

default value are those that take a default value if no arguments values are passed during the function call. You can assign this default value by with the assignment operator

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

what is a required argument ?

A

the required arguments of a UDF are those that have to be there. These arguments need to be passed during the function call and in precisely the right order.

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

what is a keyword arguments ?

A

if you want to make sure you call all the parameters in the right order, you can use the keyword arguments in your function call. You can use these to indentify the arguments by their parameter name.

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

what is a variable number of arguments ?

A

In cases where exact number of arguments are not known to pass to a function, you can use the following syntax with args or a before the parameter name in the function definition.

*args allows you to pass varying number of positional arguments.

the *args will give you all the function parameter as a tuple. This way the function will receive a tuple of arguments, and can access the items accordingly.

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

what type of file is module file ?

A

module file is (.py) containing functions or code that can be included in ones application

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

how are modules accessed in python ?

A

they are accessed using import

17
Q

how can a particular function from subset of function can be accessed.

A

modulename.subfuncsname.functionname()
* Example: numpy.linalg.det(A) # return the determinant of matrix A

18
Q

what is the keyword to only import only parts from a module ?

A

, by using the ““from”” keyword

from mymodule import my_div
r=my_div(15,3)
print (r)

When importing using the from keyword, do not use the module name when referring to elements in the module. Example: my_div(), not mymodule.my_div()

19
Q

how do explicitly import just the names you need ?

A

from module import name
#Then use name in your program