Section 2 Flashcards

1
Q

what is an args?

A

-it is a parameter (the variable listed inside the parentheses in the function definition) from https://www.w3schools.com/python/python_functions.asp#:~:text=A%20parameter%20is%20the%20variable,function%20when%20it%20is%20called.

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

How do you use args? example:

A
  • it can accept positional arguments such as (1,2,3)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How to not do a touple? aka like comma and numbers?

A

take away the * when you write the return sum(args)

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

What does the ** kwargs do??? + how

A

-you can add key words kwargs.values

add arguments like so: a=1 and it prints as—>

’ a’:1

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

what is rule ?

A

Parameters, *args, default parameters (i= ‘hi’)

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

kwargs

A

allow grab key word argument, get dictionnary and use them however we want

have atotal and return the sum.

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

what is an example of using kwargs and args?

A

def super_func(name, *args, i=’hi’ , **kwargs) :
total =0
for items in kwargs.values () :
total += items
return sum(args) + total

print(super_func(‘Andy’, 1,2,3, num1=5, num2=10))

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

what does % 2 == 0 mean??

A

means that the boolean (true or false value) whether it is equivalent to 0

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

what does .append in python?

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

what is an iterable, for example “max”??

A

an object that can repeat over

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

What is scope????? what does it mean???

A
  • what variables do I have access to?
    -that if you create a line, you have to have idententation
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Conditional block??

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

what is a local scope

A

the thing incide indentation

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

what is a parent local scope

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