Skip to content

Commit fcbf636

Browse files
committed
Day_2
1 parent 43a21dc commit fcbf636

20 files changed

Lines changed: 5957 additions & 0 deletions

‎data/rates.csv‎

Lines changed: 5701 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
2+
3+
person = { "first_name": "Kay", "last_name": "Ige"}
4+
5+
person2 = {"age": 33, **person}
6+
7+
print(person2)
8+
9+
# **other = person2
10+
11+
# there is no concept of packing in Dictionary. ** is for unpacking dictionary
12+
13+
def do_it(a: str, b: str, c:str) -> None:
14+
print(a, b, c)
15+
16+
do_it(**{"a": "1", "b": "2", "c": "3"})
17+
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
from typing import Any
2+
3+
# def do_it(a: Any = None, b: Any = None, c: Any = None) -> None:
4+
# print(a, b, c)
5+
6+
7+
# do_it(["a", "b", "c"])
8+
9+
10+
def do_it(a: Any = None, b: Any = None, *c: Any) -> None:
11+
print(a, b, c)
12+
13+
14+
do_it(1, 2, 3, 4, 5, 6, 7)
15+
16+
# asterisks applied to the argument is the unpacking.
17+
# asterisks applied to the parameters is the packing function
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
from typing import Any
2+
3+
# *args - will collect the positional arguments
4+
# **kwargs - will collect the keyword arguments
5+
6+
7+
def do_it(*args: list[Any], **kwargs: dict[str, Any]) -> None:
8+
print(args)
9+
print(kwargs)
10+
11+
# 1, 2, 3, 4 are positional arguments
12+
# a, b, c are keyword arguments
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
nums = [1, 2, 3]
2+
3+
# unpacking
4+
first, second, third = nums
5+
6+
print(first)
7+
print(second)
8+
print(third)
9+
10+
# unpacking into first, unpcking remaining elements into others <= unpacking
11+
first, *others, last = nums
12+
# ^ packing
13+
14+
print(first)
15+
print(others)
16+
print(last)
17+
18+
nums1 = [1, 2, 3, 4]
19+
nums2 = [5, 6, 7, 8]
20+
21+
nums = [*nums1, *nums2]
22+
print(nums)
23+
24+
# packing operator
25+
# *<variable> = <itirable>
26+
27+
# unpacking operator
28+
# <variable> = *<itirable>

‎demos/rates_api/__init__.py‎

Whitespace-only changes.

0 commit comments

Comments
 (0)