Welcome to day 3:
*args, **kwargs
)Remember: *There are always at least two programmers working on a given project ... *
Source: Wikipedia (from Stack Overflow Surveys)
git init
.git
where it keeps the recordsgit config [--global] user.name "Your Name Here"
git config [--global] user.email your@email.example
git add <FILE-1> [<FILE-2>, ..., <FILE-N>]
git status
git commit -m "Useful commit message"
master
branchmain
recentlymaster
/ main
reflect the latest software staterebase
)git-bash
to initialize your project directory as a git repositorygit status
<class 'dict'>
dict()
constructor 1 fruits = {
2 "apples": "usually appreciated round fruit",
3 "banana": "yellow is quite a nice color",
4 "grapes": "the basis for a good wine"
5 }
6
7 print(fruits["banana"])
8
9 fruits["banana"] = "actually, I don't like them"
10 print(fruits["banana"])
get()
is between O(1)
and O(N)
length = parameters.get("length", length_default)
1 a = set([1, 2, 5, 7, 9])
2 b = set([12, 2, 10, 9])
3 c = {4, 5, 6, 7}
4
5 a_int_b = a.intersection(b)
6 print(a_int_b)
7 >>> {9, 2}
8 c_int_a = c.intersection(a)
9 print(c_int_a)
10 >>> {5, 7}
11
12 a_union_b = a.union(b)
13 print(a_union_b)
14 >>> {1, 2, 5, 7, 9, 10, 12}
Consider the two dictionaries: {"a": 1, "b": 2, "d": 4, "f": 6}
and
{"b": 5, "c": 7, "f": 8, "g": 9}
. Write an algorithm that combines the two dictionaries
keeping only key that are present in both dicts. Add the values of these keys.
Reform the following dictionary input_dict = {'A' : {'x' : 5, 'y' : 6}, 'B' : {'x' : 1, 'y' : 4},
'C' : {'x' : 8, 'y' : 3}}
to look as follows: {'x': (5, 1, 8), 'y': (6, 4, 3)}
.
"functions are first class objects in Python"
A function...
Object
.def f(a, b, *args, c=1, **kwargs):
from within your function:
1 def f2(*args, **kwargs):
2 pos_args = args
3 print(type(pos_args))
4
5 keyword_args = kwargs
6 print(type(keyword_args))
7
8
9 f2(3, 4, a=1, b=7)
10 >>> <class 'tuple'>
11 >>> <class 'dict'>
Table of Contents | t |
---|---|
Exposé | ESC |
Presenter View | p |
Source Files | s |
Slide Numbers | n |
Toggle screen blanking | b |
Show/hide next slide | c |
Notes | 2 |
Help | h |