<jupyter_start><jupyter_text>Functional Parameters<jupyter_code>def my_func(a, b, c):
    print(f'a = {a}, b = {b}, c = {c}')
my_func(1, 2, 3) 
#positional
my_func(1, 2)
def my_func(a, b = 2, c):
    print(f'a = {a}, b = {b}, c = {c}')
def my_func(a, b = 2, c = 3):
    print(f'a = {a}, b = {b}, c = {c}')
my_func(10, 20, 30)
my_func(10, 20)
my_func(10)
def my_func(a=1, b = 2, c = 3):
    print(f'a = {a}, b = {b}, c = {c}')
my_func()
def my_func(a, b = 2, c = 3):
    print(f'a = {a}, b = {b}, c = {c}')
my_func(c = 30, b = 20, a = 10)
my_func(30, c = 20, b = 10)
my_func(10, c = 30)
a = (1, 2, 3)
type(a)
a = 1, 2, 3
type(a)
a
print(a)
a = (1) * 3
type(a)
a = 1, 
type(a)
ip_add = 256, 
user = "admin"
a = (1,)
type(a)
a = ()
type(a)
a = (,)
a, b, c = 1, 'a', 3.14
a, b, c
a
[a, b, c] = [1, 'a', 3.14]
a
(a, b, c) = [1, 'a', 3.14]
c
(a, b, c) = (1*4, 'a'*3, 3.14/3.14)
a, b, c
a, b, c = 10, {1, 2}, ['a', 'b']
c[1]
# swapping variables
a, b = 10, 20

b, a = a, b
a, b
a, b = 10, 20
print(id(a), id(b))
b, a = a, b
print(id(b), id(a))
for e in 'UMBRELLA ACADEMY':
    print(e)
a, b, c, d = 'POGO'
a, b, d
s = 'XYZ'

s[0]
s = {1, 2, 3}

s[0]
s = {'c', 'o', 'v', 'i', 'd', '19'}
print(s)
print(s)
s
s
print(s)
for e in s:
    print(e)
a, b, c, d, e, f = s
a, b, c
d = {'key1': 1, 'key2': 2, 'key3': 'c'}
for e in d:
    print(e)
a, b, c = d
a
d = {'a': 1, 'b': 2, 'c': 'c', 'd': 4}
a, b, c, d = d
d
c = {'a': 1, 'b': 2, 'c': 'c', 'd': 4}
d = {a: 1, 'b': 2, 'c': 3, 'd': 4}
for e in d.values():
    print(e)
a, b, c, d = d.values()
a, b,
type(d)
d = {a: 1, 'b': 2, 'c': 3, 'd': 4}
type(d.values())
dict1 = {'a': 1, 'b': 2, 'c': 3, 'd': 4}
for e in dict1.items():
    print(e)
for a, b in dict1.items():
    print(a, b)
d1 = {'p': 1, 'y': 2}
d2 = {'t': 3, 'h': 4}
d3 = {'h': 5, 'o': 6, 'n': 7}
d = {**d1, **d2, **d3}
d
l = [1, 2, 3, 4, 5, 6]
a = l[0]
b = l[1:]
b
l = [1, 2, 3, 4, 5, 6]
a, *b = l
print(f'a is {a} and b is {b}')
l = [1]
a, *b = l
print(f'a is {a} and b is {b}')
s = {1, 2, 3, 4}
a = s[0]
b = s[1:]
s = 'python'
a, *b = s
print(f'a is {a} and b is {b} and b will be a list')
t = ('a', 'b', 'c')
a, *b = t
print(f'a is {a} and b is {b}')
[a, *b] = "python"
print(f'a is {a} and b is {b}')
a, b, *c = "python"
print(f'a is {a}, b is {b}, and c is {c}')
a, b, *c, d = "python"
print(f'a is {a}, b is {b}, c is {c}, and d is {d}')
a, b, *c, d, e = "abcl"
print(f'a is {a}, b is {b}, c is {c}, and d is {d}, and e is {e}')
a, b, *c, d = "python"
print(f'a is {a}, b is {b}, c is {c}, and d is {d}')
a, b, c, d = s[0], s[1], s[2:-1], s[-1]
print(f'a is {a}, b is {b}, c is {list(c)}, and d is {d}')
c = 'tho'
c = 'tho'
*c, = c
c
c
l1 = [1, 2, 3]
l2 = [4, 5, 6]

l = [*l1, *l2]

l
l = [l1, l2]

l
l = l1 + l2
l
l1 = [1, 2, 3]
s = 'abc'

[*l1, *s]
l1 = [1, 2, 3]
s1 = {'x', 'y', 'z'}

[*l1, *s1]
s1 = 'abc'
s2 = 'cde'
[*s1, *s2]
{*s1, *s2}
s = {10, 99, 3, 'd'}

for c in s:
    print(c)
a, b, c, d = s
list(s)
d = 'tho'
(*d) = d
d
s1 = {1, 2, 3}
s2 = {3, 4, 5}
s1 + s2
s1 = [1, 2, 3]
s2 = [3, 4, 5]
s1 + s2
{*s1, *s2}
s1 = {1, 2, 3}
s2 = {3, 4, 5}
s1.union(s2)
s1 = {1, 2, 3}
s2 = {3, 4, 5}
s3 = {6, 7, 8}
s4 = {9, 4, 3}
s1.union(s2).union(s3).union(s4)
s1.union(s2, s3, s4)
{*s1, *s2, *s3, *s4}
[*s1, *s2, *s3, *s4]
d1 = {'key1': 1, 'key2': 2}
d2 = {'key2': 3, 'key3': 4}
{*d1, *d2}
{**d1, **d2}
{**d2, **d1}
{'a': 1, 'b': 2, **d1, 'c': 3}
a, b, e = [1, 2, 'XY']
e
a, b, (c, *d) = [1, 2, 'XYASDFASDASJHDASJDSADJ']
c
l =  [1, 2, 3, 4, 'python']

a, *b, (c, d, *e) = l

print(a, b, c, d, e)
a, b, *c = 10, 20, 'a', 'b'
c
def func1(a, b, *c):
    print(a)
    print(b)
    print(c)
func1(10, 20) # optional
func1(10, 20, 30, 40)
def avg(*args):
    print(args)
avg()
avg(10, 20)
def avg(*args):
    count = len(args)
    total = sum(args)
    return total/count
avg(10, 20) #works!
avg()
def avg(*args):
    count = len(args)
    total = sum(args)
    return count and total/count

print(avg(), avg(10, 20, 30, 40))
def avg(a, *args):
    count = len(args) + 1
    total = sum(args) + a
    return count and total/count
avg(1)    
avg(10, 20, 30, 40)
def func1(a, b, c):
    print(a)
    print(b)
    print(c)
l = [10, 20, 30]
func1(l)
func1(*l)
# but what if
l = [10, 20, 30, 40]
func1(*l)
def func1(a, b, *args):
    print(a)
    print(b)
    print(args)
l = [10, 20, 30, 40]
func1(*l)
def func1(a, b, c):
    print(a, b, c)
func1(1, 2, 3)
func1(a = 1, c = 3, b = 2)
def func1(a, b, *args):
    print(a, b, args)
func1(1, 2, 3, 4, 5)
def func1(a, b, *args, d):
    print(a, b, args, d)
func1(1, 2, 3, 4, 5)
func1(1, 2, 3, 4, d = 5)
def func1(*args, d):
    print(args, d)
func1(1, 2, 3)
func1(1, 2, 3, d = 4)
func1(d = 100)
# no positional arguments

def func1(a, b, c, *, d):
    print(d)

func1(1, 2, d = 3)
def func(a, b, *, d):
    print(a, b, d)

func(1, 2, 3, d = 4)
func(1, 2, d = 4)
def func2(a, b = 1, c):
    print(a, b, c)
def func(a, b = 1, *args, d):
    print(a, b, args, d)
func(1, 5, 3, 4, 5, d = 'a')
def func(a, b = 20, *args, d = 0, e):
    print(a, b, args, d, e)
func(5, 4, 3, 2, 1, e = 5)
func(0, 600, e='crabs')
def func(**others):
    print(others)
func(a = 1, b = 2, c = 3)
def func(*args, **kwargs):
    print(args)
    print(kwargs)
func(1, 2, 3, 4, a = 1, b = 2, c = 3)
func(1, 2, 3, 4, a = 1, b = 2, c = 3, 4)
def func(a, b, *, **kwargs):
    print(a)
    print(b)
    print(kwargs)
def func(a, b, *, d, **kwargs):
    print(a)
    print(b)
    print(d)
    print(kwargs)
func(1, 2, x = 100, y = 100)
func(1, 2, x = 100, y = 100, d = 100)
func(d = 100, 1, 2, x = 100, y = 100)
def func(a, b, **kwargs):
    print(a)
    print(b)
    print(kwargs)
func(1, 2, x = 100, y = 200)
def func(a, b, *args):
    print(a, b, args)
func(1, 2, 'x', 'y', 'z')
func(a = 1, b = 2, 'x', 'y', 'z') # incorrect
def func(a, b = 2, c = 3, *args):
    print(a, b, c, args)
func(1, 4, 3, 'x', 'y', 'z')
func(1, c=5)
func(1, c = 5, 'x', 'y')
def func(a, b = 2, *args, c=3, d):
    print(a, b, args, c, d)
func(10, 20, 'x', 'y', 'z', c = 4, d = 1)
func(10, 20, 'x', 'y', 'z', d = 1)
# def func(a, b = 2, *args, c=3, d):
func(1, 'x', 'y', 'z', b = 4, d = 10)
func(1, 'x', 'y', 'z', d = 10)
def func(a, b, *args, c = 10, d = 20, **kwargs):
    print(a, b, args, c, d, kwargs)
func(1, 2, 'x', 'y', 'z', c=100, d=200, x=0.1, y=0.2)
print(1, 2, 3, sep='-', )
print(1, 2, 3, sep='-', end=' *** ')<jupyter_output>1-2-3
1-2-3 ***
{'fraction_non_alphanumeric': 0.28241983888801137, 'fraction_numerical': 0.08797978202495656, 'mean_word_length': 2.814457831325301, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '201455', 'license': 'MIT', 'n_tokens_mistral': 3896, 'n_tokens_neox': 3543, 'n_words': 1182, 'path': 'Session05_Functional Parameters/notebooks/Session05_ClassRoom.ipynb', 'repo_name': 'abdksyed/EPAi', 'size': '6331'}