Section 2 Flashcards
what is an args?
-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 do you use args? example:
- it can accept positional arguments such as (1,2,3)
How to not do a touple? aka like comma and numbers?
take away the * when you write the return sum(args)
What does the ** kwargs do??? + how
-you can add key words kwargs.values
add arguments like so: a=1 and it prints as—>
’ a’:1
what is rule ?
Parameters, *args, default parameters (i= ‘hi’)
kwargs
allow grab key word argument, get dictionnary and use them however we want
have atotal and return the sum.
what is an example of using kwargs and args?
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))
what does % 2 == 0 mean??
means that the boolean (true or false value) whether it is equivalent to 0
what does .append in python?
- to add
what is an iterable, for example “max”??
an object that can repeat over
What is scope????? what does it mean???
- what variables do I have access to?
-that if you create a line, you have to have idententation
Conditional block??
what is a local scope
the thing incide indentation
what is a parent local scope