├── .github ├── CODEOWNERS ├── ISSUE_TEMPLATE.md └── PULL_REQUEST_TEMPLATE.md ├── .gitignore ├── 01 Language ├── assign1_finished.py ├── assign1_start.py ├── assign2_finished.py ├── assign2_start.py ├── codingstyle_finished.py ├── strings_finished.py ├── strings_start.py ├── templstr_finished.py └── templstr_start.py ├── 02 BuiltIn Functions ├── iterators_finished.py ├── iterators_start.py ├── itertools_finished.py ├── itertools_start.py ├── testfile.txt ├── transforms_finished.py ├── transforms_start.py ├── utilfuncs_finished.py └── utilfuncs_start.py ├── 03 Functions ├── docstrings_finished.py ├── docstrings_start.py ├── keyargs_finished.py ├── keyargs_start.py ├── lambdas_finished.py ├── lambdas_start.py ├── varargs_finished.py └── varargs_start.py ├── 04 Collections ├── counter_finished.py ├── counter_start.py ├── defaultdict_finished.py ├── defaultdict_start.py ├── deque_finished.py ├── deque_start.py ├── namedtup_finished.py ├── namedtup_start.py ├── ordereddict_finished.py └── ordereddict_start.py ├── 05 Classes ├── comparison_finished.py ├── comparison_start.py ├── compattrs_finished.py ├── compattrs_start.py ├── enums_finished.py ├── enums_start.py ├── numeric_finished.py ├── numeric_finished_warning.py ├── numeric_start.py ├── objectstrs_finished.py └── objectstrs_start.py ├── 06 Logging ├── basiclog_finished.py ├── basiclog_start.py ├── customlog_finished.py └── customlog_start.py ├── 07 Comprehensions ├── dictcomp_finished.py ├── dictcomp_start.py ├── listcomp_finished.py ├── listcomp_start.py ├── setcomp_finished.py └── setcomp_start.py ├── 08 Pattern Matching ├── Program.cs ├── SwitchCase1.java ├── SwitchCase1.js ├── SwitchCase2.java ├── SwitchCase2.js ├── capture_finished.py ├── capture_start.py ├── class_finished.py ├── class_start.py ├── guards1_finished.py ├── guards1_start.py ├── guards2_finished.py ├── guards2_start.py ├── sequence_finished.py ├── sequence_start.py ├── simple_finished.py └── simple_start.py ├── CONTRIBUTING.md ├── LICENSE ├── NOTICE └── README.md /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | # Codeowners for these exercise files: 2 | # * (asterisk) deotes "all files and folders" 3 | # Example: * @producer @instructor 4 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 7 | 8 | ## Issue Overview 9 | 10 | 11 | ## Describe your environment 12 | 13 | 14 | ## Steps to Reproduce 15 | 16 | 1. 17 | 2. 18 | 3. 19 | 4. 20 | 21 | ## Expected Behavior 22 | 23 | 24 | ## Current Behavior 25 | 26 | 27 | ## Possible Solution 28 | 29 | 30 | ## Screenshots / Video 31 | 32 | 33 | ## Related Issues 34 | 35 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | .tmp 4 | npm-debug.log 5 | -------------------------------------------------------------------------------- /01 Language/assign1_finished.py: -------------------------------------------------------------------------------- 1 | # The assignment expression operator := (or the "walrus" operator) 2 | 3 | import pprint 4 | 5 | 6 | # regular assignment statements assign a value 7 | x = 5 8 | print(x) 9 | 10 | # the assignment operator is part of an expression 11 | (x := 5) 12 | print(x) 13 | 14 | # The assignment expression is useful for writing concise code 15 | 16 | while (thestr := input("Value? ")) != "exit": 17 | print(thestr) 18 | 19 | -------------------------------------------------------------------------------- /01 Language/assign1_start.py: -------------------------------------------------------------------------------- 1 | # The assignment expression operator := (or the "walrus" operator) 2 | 3 | import pprint 4 | 5 | 6 | # regular assignment statements assign a value 7 | x = 5 8 | print(x) 9 | 10 | # TODO: the assignment operator is part of an expression 11 | 12 | 13 | # TODO: The assignment expression is useful for writing concise code 14 | 15 | -------------------------------------------------------------------------------- /01 Language/assign2_finished.py: -------------------------------------------------------------------------------- 1 | # Example file for Advanced Python: Language Features by Joe Marini 2 | # The assignment expression operator := (or the "walrus" operator) 3 | 4 | import pprint 5 | 6 | 7 | # The walrus operator can help reduce redundant function calls 8 | values = [12, 0, 10, 5, 9, 18, 41, 23, 30, 16, 18, 9, 18, 22] 9 | val_data = { 10 | "length": (l := len(values)), 11 | "total": (s := sum(values)), 12 | "average": s / l 13 | } 14 | pprint.pp(val_data) 15 | -------------------------------------------------------------------------------- /01 Language/assign2_start.py: -------------------------------------------------------------------------------- 1 | # The assignment expression operator := (or the "walrus" operator) 2 | 3 | import pprint 4 | 5 | 6 | 7 | # TODO: The walrus operator can help reduce redundant function calls 8 | values = [12, 0, 10, 5, 9, 18, 41, 23, 30, 16, 18, 9, 18, 22] 9 | val_data = { 10 | "length": len(values), 11 | "total": sum(values), 12 | "average": sum(values) / len(values) 13 | } 14 | -------------------------------------------------------------------------------- /01 Language/codingstyle_finished.py: -------------------------------------------------------------------------------- 1 | # imports go on their own lines 2 | import sys 3 | import os 4 | 5 | 6 | # two blank lines separate classes from other functions 7 | class MyClass(): 8 | def __init__(self): 9 | self.prop1 = "my class" 10 | 11 | # within classes, one blank line separates methods 12 | def method1(self, arg1): 13 | pass 14 | 15 | 16 | def main(): 17 | # Long comments, like this one that flow across several lines, are 18 | # limited to 72 characters instead of 79 for lines of code. 19 | cls1 = MyClass() 20 | cls1.prop1 = "hello world" 21 | 22 | 23 | if __name__ == "__main__": 24 | main() 25 | -------------------------------------------------------------------------------- /01 Language/strings_finished.py: -------------------------------------------------------------------------------- 1 | # strings and bytes are not directly interchangeable 2 | # strings contain unicode, bytes are raw 8-bit values 3 | 4 | def main(): 5 | # define some starting values 6 | b = bytes([0x41, 0x42, 0x43, 0x44]) 7 | print(b) 8 | 9 | s = "This is a string" 10 | print(s) 11 | 12 | # Try combining them. This will cause an error: 13 | # print(s+b) 14 | 15 | # Bytes and strings need to be properly encoded and decoded 16 | # before you can work on them together 17 | s2 = b.decode('utf-8') 18 | print(s+s2) 19 | 20 | b2 = s.encode('utf-8') 21 | print(b+b2) 22 | 23 | # encode the string as UTF-32 24 | b3 = s.encode('utf-32') 25 | print(b3) 26 | 27 | if __name__ == "__main__": 28 | main() 29 | -------------------------------------------------------------------------------- /01 Language/strings_start.py: -------------------------------------------------------------------------------- 1 | # strings and bytes are not directly interchangeable 2 | # strings contain unicode, bytes are raw 8-bit values 3 | 4 | def main(): 5 | # define some starting values 6 | b = bytes([0x41, 0x42, 0x43, 0x44]) 7 | print(b) 8 | 9 | s = "This is a string" 10 | print(s) 11 | 12 | # TODO: Try combining them. 13 | 14 | # TODO: Bytes and strings need to be properly encoded and decoded 15 | # before you can work on them together 16 | 17 | # TODO: encode the string as UTF-32 18 | 19 | if __name__ == "__main__": 20 | main() 21 | -------------------------------------------------------------------------------- /01 Language/templstr_finished.py: -------------------------------------------------------------------------------- 1 | # demonstrate template string functions 2 | from string import Template 3 | 4 | def main(): 5 | # Usual string formatting with format() 6 | str1 = "Das ist der Kurs '{0}' von {1}".format("Fortgeschrittene Python-Techniken", "Joe Marini und Ralph Steyer") 7 | print(str1) 8 | 9 | # TODO: create a template with placeholders 10 | templ = Template("Das ist der Kurs '${title}' von ${authors}") 11 | 12 | # TODO: use the substitute method with keyword arguments 13 | str2 = templ.substitute(title="Fortgeschrittene Python-Techniken", authors="Joe Marini und Ralph Steyer") 14 | print(str2) 15 | 16 | # TODO: use the substitute method with a dictionary 17 | data = { 18 | "authors":"Joe Marini und Ralph Steyer", 19 | "title":"Fortgeschrittene Python-Techniken" 20 | 21 | } 22 | str3 = templ.substitute(data) 23 | print(str3) 24 | 25 | 26 | if __name__ == "__main__": 27 | main() 28 | -------------------------------------------------------------------------------- /01 Language/templstr_start.py: -------------------------------------------------------------------------------- 1 | # demonstrate template string functions 2 | from string import Template 3 | 4 | def main(): 5 | # Usual string formatting with format() 6 | str1 = "Das ist der Kurs '{0}' von {1}".format("Fortgeschrittene Python-Techniken", "Joe Marini und Ralph Steyer") 7 | print(str1) 8 | 9 | # TODO: create a template with placeholders 10 | 11 | # TODO: use the substitute method with keyword arguments 12 | 13 | # TODO: use the substitute method with a dictionary 14 | 15 | 16 | if __name__ == "__main__": 17 | main() 18 | -------------------------------------------------------------------------------- /02 BuiltIn Functions/iterators_finished.py: -------------------------------------------------------------------------------- 1 | # use iterator functions like enumerate, zip, iter, next 2 | 3 | 4 | def main(): 5 | # define a list of days in English and German 6 | days = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"] 7 | daysGer = ["So", "Mo", "Di", "Mi", "Do", "Fr", "Sa"] 8 | 9 | # use iter to create an iterator over a collection 10 | i = iter(days) 11 | print(next(i)) # Sun 12 | print(next(i)) # Mon 13 | print(next(i)) # Tue 14 | 15 | # iterate using a function and a sentinel 16 | with open("testfile.txt", "r") as fp: 17 | for line in iter(fp.readline, ''): 18 | print(line) 19 | 20 | # use regular interation over the days 21 | for m in range(len(days)): 22 | print(m+1, days[m]) 23 | 24 | # using enumerate reduces code and provides a counter 25 | for i, m in enumerate(days, start=1): 26 | print(i, m) 27 | 28 | # use zip to combine sequences 29 | for m in zip(days, daysGer): 30 | print(m) 31 | 32 | for i, m in enumerate(zip(days, daysGer), start=1): 33 | print(i, m[0], "=", m[1], "in German") 34 | 35 | 36 | if __name__ == "__main__": 37 | main() 38 | -------------------------------------------------------------------------------- /02 BuiltIn Functions/iterators_start.py: -------------------------------------------------------------------------------- 1 | # use iterator functions like enumerate, zip, iter, next 2 | 3 | 4 | def main(): 5 | # define a list of days in English and German 6 | days = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"] 7 | daysGer = ["So", "Mo", "Di", "Mi", "Do", "Fr"] 8 | 9 | # TODO: use iter to create an iterator over a collection 10 | i = iter(days) 11 | #print(next(i)) 12 | #print(next(i)) 13 | #print(next(i)) 14 | 15 | 16 | # TODO: iterate using a function and a sentinel 17 | #with open("testfile.txt","r") as fp: 18 | # for line in iter(fp.readline,''): 19 | # print(line) 20 | 21 | # TODO: use regular interation over the days 22 | for m in range(len(days)): 23 | print(m + 1, days[m]) 24 | 25 | # TODO: using enumerate reduces code and provides a counter 26 | for i,m in enumerate(days, start=1): 27 | print(i, m) 28 | 29 | # TODO: use zip to combine sequences 30 | for i,m in enumerate(zip(days,daysGer),start=1): 31 | print(i,m[0],"=", m[1], "in German") 32 | 33 | 34 | if __name__ == "__main__": 35 | main() 36 | -------------------------------------------------------------------------------- /02 BuiltIn Functions/itertools_finished.py: -------------------------------------------------------------------------------- 1 | # advanced iteration functions in the itertools package 2 | 3 | import itertools 4 | 5 | 6 | def testFunction(x): 7 | return x < 40 8 | 9 | 10 | def main(): 11 | # cycle iterator can be used to cycle over a collection 12 | seq1 = ["Joe", "John", "Mike"] 13 | cycle1 = itertools.cycle(seq1) 14 | print(next(cycle1)) 15 | print(next(cycle1)) 16 | print(next(cycle1)) 17 | print(next(cycle1)) 18 | 19 | # use count to create a simple counter 20 | count1 = itertools.count(100, 10) 21 | print(next(count1)) 22 | print(next(count1)) 23 | print(next(count1)) 24 | 25 | # accumulate creates an iterator that accumulates values 26 | vals = [10,20,30,40,50,40,30] 27 | acc = itertools.accumulate(vals, max) 28 | print(list(acc)) 29 | 30 | # use chain to connect sequences together 31 | x = itertools.chain("ABCD", "1234") 32 | print(list(x)) 33 | 34 | # dropwhile and takewhile will return values until 35 | # a certain condition is met that stops them 36 | print(list(itertools.dropwhile(testFunction, vals))) 37 | print(list(itertools.takewhile(testFunction, vals))) 38 | 39 | 40 | if __name__ == "__main__": 41 | main() 42 | -------------------------------------------------------------------------------- /02 BuiltIn Functions/itertools_start.py: -------------------------------------------------------------------------------- 1 | # advanced iteration functions in the itertools package 2 | 3 | 4 | def testFunction(x): 5 | pass 6 | 7 | 8 | def main(): 9 | # TODO: cycle iterator can be used to cycle over a collection 10 | seq1 = ["Joe", "John", "Mike"] 11 | 12 | # TODO: use count to create a simple counter 13 | 14 | # TODO: accumulate creates an iterator that accumulates values 15 | vals = [10,20,30,40,50,40,30] 16 | 17 | # TODO: use chain to connect sequences together 18 | 19 | # TODO: dropwhile and takewhile will return values until 20 | # a certain condition is met that stops them 21 | 22 | 23 | if __name__ == "__main__": 24 | main() 25 | -------------------------------------------------------------------------------- /02 BuiltIn Functions/testfile.txt: -------------------------------------------------------------------------------- 1 | This is line 1 2 | This is line 2 3 | This is line 3 4 | This is line 4 5 | This is line 5 6 | This is line 6 7 | -------------------------------------------------------------------------------- /02 BuiltIn Functions/transforms_finished.py: -------------------------------------------------------------------------------- 1 | # use transform functions like sorted, filter, map 2 | 3 | 4 | def filterFunc(x): 5 | if x % 2 == 0: 6 | return False 7 | return True 8 | 9 | 10 | def filterFunc2(x): 11 | if x.isupper(): 12 | return False 13 | return True 14 | 15 | 16 | def squareFunc(x): 17 | return x**2 18 | 19 | 20 | def toGrade(x): 21 | if (x >= 90): 22 | return "A" 23 | elif (x >= 80 and x < 90): 24 | return "B" 25 | elif (x >= 70 and x < 80): 26 | return "C" 27 | elif (x >= 65 and x < 70): 28 | return "D" 29 | return "F" 30 | 31 | 32 | def main(): 33 | # define some sample sequences to operate on 34 | nums = (1, 8, 4, 5, 13, 26, 381, 410, 58, 47) 35 | chars = "abcDeFGHiJklmnoP" 36 | grades = (81, 89, 94, 78, 61, 66, 99, 74) 37 | 38 | # use filter to remove items from a list 39 | odds = list(filter(filterFunc, nums)) 40 | print(odds) 41 | 42 | # use filter on non-numeric sequence 43 | lowers = list(filter(filterFunc2, chars)) 44 | print(lowers) 45 | 46 | # use map to create a new sequence of values 47 | squares = list(map(squareFunc, nums)) 48 | print(squares) 49 | 50 | # use sorted and map to change numbers to grades 51 | grades = sorted(grades) 52 | letters = list(map(toGrade, grades)) 53 | print(letters) 54 | 55 | 56 | if __name__ == "__main__": 57 | main() 58 | -------------------------------------------------------------------------------- /02 BuiltIn Functions/transforms_start.py: -------------------------------------------------------------------------------- 1 | # use transform functions like sorted, filter, map 2 | 3 | 4 | def filterFunc(x): 5 | pass 6 | 7 | 8 | def filterFunc2(x): 9 | pass 10 | 11 | 12 | def squareFunc(x): 13 | pass 14 | 15 | 16 | def toGrade(x): 17 | pass 18 | 19 | 20 | def main(): 21 | # define some sample sequences to operate on 22 | nums = (1, 8, 4, 5, 13, 26, 381, 410, 58, 47) 23 | chars = "abcDeFGHiJklmnoP" 24 | grades = (81, 89, 94, 78, 61, 66, 99, 74) 25 | 26 | # TODO: use filter to remove items from a list 27 | 28 | # TODO: use filter on non-numeric sequence 29 | 30 | # TODO: use map to create a new sequence of values 31 | 32 | # TODO: use sorted and map to change numbers to grades 33 | 34 | 35 | if __name__ == "__main__": 36 | main() 37 | -------------------------------------------------------------------------------- /02 BuiltIn Functions/utilfuncs_finished.py: -------------------------------------------------------------------------------- 1 | # demonstrate built-in utility functions 2 | 3 | 4 | def main(): 5 | # use any() and all() to test sequences for boolean values 6 | list1 = [1, 2, 3, 4, 5, 6] 7 | 8 | # any will return true if any of the sequence values are true 9 | print(any(list1)) 10 | 11 | # all will return true only if all values are true 12 | print(all(list1)) 13 | 14 | # min and max will return minimum and maximum values in a sequence 15 | print("min: ", min(list1)) 16 | print("max: ", max(list1)) 17 | 18 | # Use sum() to sum up all of the values in a sequence 19 | print("sum: ", sum(list1)) 20 | 21 | 22 | if __name__ == "__main__": 23 | main() 24 | -------------------------------------------------------------------------------- /02 BuiltIn Functions/utilfuncs_start.py: -------------------------------------------------------------------------------- 1 | # demonstrate built-in utility functions 2 | 3 | 4 | def main(): 5 | # use any() and all() to test sequences for boolean values 6 | list1 = [1, 2, 3, 0, 5, 6] 7 | 8 | # TODO: any will return true if any of the sequence values are true 9 | 10 | # TODO: all will return true only if all values are true 11 | 12 | # TODO: min and max will return minimum and maximum values in a sequence 13 | 14 | # TODO: Use sum() to sum up all of the values in a sequence 15 | 16 | if __name__ == "__main__": 17 | main() 18 | -------------------------------------------------------------------------------- /03 Functions/docstrings_finished.py: -------------------------------------------------------------------------------- 1 | # Demonstrate the use of function docstrings 2 | 3 | 4 | def myFunction(arg1, arg2=None): 5 | """myFunction(arg1, arg2=None) --> Doesn't really do anything special. 6 | 7 | Parameters: 8 | arg1: the first argument. Whatever you feel like passing. 9 | arg2: the second argument. Defaults to None. Whatever makes you happy. 10 | """ 11 | print(arg1, arg2) 12 | 13 | 14 | def main(): 15 | print(myFunction.__doc__) 16 | 17 | 18 | if __name__ == "__main__": 19 | main() 20 | -------------------------------------------------------------------------------- /03 Functions/docstrings_start.py: -------------------------------------------------------------------------------- 1 | # Demonstrate the use of function docstrings 2 | 3 | 4 | def myFunction(arg1, arg2=None): 5 | print(arg1, arg2) 6 | 7 | 8 | def main(): 9 | print(myFunction.__doc__) 10 | 11 | 12 | if __name__ == "__main__": 13 | main() 14 | -------------------------------------------------------------------------------- /03 Functions/keyargs_finished.py: -------------------------------------------------------------------------------- 1 | # Demonstrate the use of keyword-only arguments 2 | 3 | 4 | # use keyword-only arguments to help ensure code clarity 5 | def myFunction(arg1, arg2, *, suppressExceptions=False): 6 | pass 7 | 8 | 9 | def main(): 10 | # try to call the function without the keyword 11 | #myFunction(1, 2, True) 12 | myFunction(1, 2, suppressExceptions=True) 13 | myFunction(1, 2) 14 | 15 | if __name__ == "__main__": 16 | main() 17 | -------------------------------------------------------------------------------- /03 Functions/keyargs_start.py: -------------------------------------------------------------------------------- 1 | # Demonstrate the use of keyword-only arguments 2 | 3 | 4 | # use keyword-only arguments to help ensure code clarity 5 | def myFunction(): 6 | pass 7 | 8 | 9 | def main(): 10 | # try to call the function without the keyword 11 | myFunction(1, 2, True) 12 | 13 | 14 | if __name__ == "__main__": 15 | main() 16 | -------------------------------------------------------------------------------- /03 Functions/lambdas_finished.py: -------------------------------------------------------------------------------- 1 | # Use lambdas as in-place functions 2 | 3 | 4 | def CelsisusToFahrenheit(temp): 5 | return (temp * 9/5) + 32 6 | 7 | 8 | def FahrenheitToCelsisus(temp): 9 | return (temp-32) * 5/9 10 | 11 | 12 | def main(): 13 | ctemps = [0, 12, 34, 100] 14 | ftemps = [32, 65, 100, 212] 15 | 16 | # Use regular functions to convert temps 17 | print(list(map(FahrenheitToCelsisus, ftemps))) 18 | print(list(map(CelsisusToFahrenheit, ctemps))) 19 | 20 | # Use lambdas to accomplish the same thing 21 | print(list(map(lambda t: (t-32) * 5/9, ftemps))) 22 | print(list(map(lambda t: (t * 9/5) + 32, ctemps))) 23 | 24 | 25 | if __name__ == "__main__": 26 | main() 27 | -------------------------------------------------------------------------------- /03 Functions/lambdas_start.py: -------------------------------------------------------------------------------- 1 | # Use lambdas as in-place functions 2 | 3 | 4 | def CelsisusToFahrenheit(temp): 5 | return (temp * 9/5) + 32 6 | 7 | 8 | def FahrenheitToCelsisus(temp): 9 | return (temp-32) * 5/9 10 | 11 | 12 | def main(): 13 | ctemps = [0, 12, 34, 100] 14 | ftemps = [32, 65, 100, 212] 15 | 16 | # TODO: Use regular functions to convert temps 17 | 18 | # TODO: Use lambdas to accomplish the same thing 19 | 20 | 21 | if __name__ == "__main__": 22 | main() 23 | -------------------------------------------------------------------------------- /03 Functions/varargs_finished.py: -------------------------------------------------------------------------------- 1 | # Demonstrate the use of variable argument lists 2 | 3 | 4 | # define a function that takes variable arguments 5 | def addition(base, *args): 6 | result = 0 7 | for arg in args: 8 | result += arg 9 | 10 | return result 11 | 12 | 13 | def main(): 14 | # pass different arguments 15 | print(addition(5, 10, 15, 20)) 16 | print(addition(1, 2, 3)) 17 | 18 | # pass an existing list 19 | myNums = [5, 10, 15, 20] 20 | print(addition(*myNums)) 21 | 22 | 23 | if __name__ == "__main__": 24 | main() 25 | -------------------------------------------------------------------------------- /03 Functions/varargs_start.py: -------------------------------------------------------------------------------- 1 | # Demonstrate the use of variable argument lists 2 | 3 | 4 | # TODO: define a function that takes variable arguments 5 | def addition(): 6 | pass 7 | 8 | 9 | def main(): 10 | # TODO: pass different arguments 11 | print(addition()) 12 | 13 | # TODO: pass an existing list 14 | 15 | 16 | if __name__ == "__main__": 17 | main() 18 | -------------------------------------------------------------------------------- /04 Collections/counter_finished.py: -------------------------------------------------------------------------------- 1 | # Demonstrate the usage of Counter objects 2 | 3 | from collections import Counter 4 | 5 | 6 | def main(): 7 | # list of students in class 1 8 | class1 = ["Bob", "Becky", "Chad", "Darcy", "Frank", "Hannah" 9 | "Kevin", "James", "James", "Melanie", "Penny", "Steve"] 10 | 11 | # list of students in class 2 12 | class2 = ["Bill", "Barry", "Cindy", "Debbie", "Frank", 13 | "Gabby", "Kelly", "James", "Joe", "Sam", "Tara", "Ziggy"] 14 | 15 | # TODO: Create a Counter for class1 and class2 16 | c1 = Counter(class1) 17 | c2 = Counter(class2) 18 | 19 | # TODO: How many students in class 1 named James? 20 | print(c1["James"]) 21 | 22 | # TODO: How many students are in class 1? 23 | print(sum(c1.values()), " Studenten in Klasse 1") 24 | 25 | # TODO: Combine the two classes 26 | c1.update(class2) 27 | print(sum(c1.values()), " Studenten in Klasse 1 und 2") 28 | 29 | # TODO: What's the most common name in the two classes? 30 | print(c1.most_common(3)) 31 | 32 | # TODO: Separate the classes again 33 | c1.subtract(class2) 34 | print(c1.most_common(3)) 35 | 36 | # TODO: What's common between the two classes? 37 | print(c1 & c2) 38 | 39 | 40 | 41 | if __name__ == "__main__": 42 | main() 43 | -------------------------------------------------------------------------------- /04 Collections/counter_start.py: -------------------------------------------------------------------------------- 1 | # Demonstrate the usage of Counter objects 2 | 3 | from collections import Counter 4 | 5 | 6 | def main(): 7 | # list of students in class 1 8 | class1 = ["Bob", "Becky", "Chad", "Darcy", "Frank", "Hannah" 9 | "Kevin", "James", "James", "Melanie", "Penny", "Steve"] 10 | 11 | # list of students in class 2 12 | class2 = ["Bill", "Barry", "Cindy", "Debbie", "Frank", 13 | "Gabby", "Kelly", "James", "Joe", "Sam", "Tara", "Ziggy"] 14 | 15 | # TODO: Create a Counter for class1 and class2 16 | 17 | # TODO: How many students in class 1 named James? 18 | 19 | # TODO: How many students are in class 1? 20 | 21 | # TODO: Combine the two classes 22 | 23 | # TODO: What's the most common name in the two classes? 24 | 25 | # TODO: Separate the classes again 26 | 27 | # TODO: What's common between the two classes? 28 | 29 | 30 | if __name__ == "__main__": 31 | main() 32 | -------------------------------------------------------------------------------- /04 Collections/defaultdict_finished.py: -------------------------------------------------------------------------------- 1 | # Demonstrate the usage of defaultdict objects 2 | 3 | from collections import defaultdict 4 | 5 | 6 | def main(): 7 | # define a list of items that we want to count 8 | fruits = ['apple', 'pear', 'orange', 'banana', 9 | 'apple', 'grape', 'banana', 'banana'] 10 | 11 | # use a dictionary to count each element 12 | fruitCounter = defaultdict(int) 13 | 14 | # Count the elements in the list 15 | for fruit in fruits: 16 | fruitCounter[fruit] += 1 17 | 18 | # print the result 19 | for (k, v) in fruitCounter.items(): 20 | print(k + ": " + str(v)) 21 | 22 | 23 | if __name__ == "__main__": 24 | main() 25 | -------------------------------------------------------------------------------- /04 Collections/defaultdict_start.py: -------------------------------------------------------------------------------- 1 | # Demonstrate the usage of defaultdict objects 2 | 3 | 4 | def main(): 5 | # define a list of items that we want to count 6 | fruits = ['apple', 'pear', 'orange', 'banana', 7 | 'apple', 'grape', 'banana', 'banana'] 8 | 9 | # use a dictionary to count each element 10 | fruitCounter = {} 11 | 12 | # Count the elements in the list 13 | for fruit in fruits: 14 | fruitCounter[fruit] += 1 15 | 16 | # print the result 17 | for (k, v) in fruitCounter.items(): 18 | print(k + ": " + str(v)) 19 | 20 | 21 | if __name__ == "__main__": 22 | main() 23 | -------------------------------------------------------------------------------- /04 Collections/deque_finished.py: -------------------------------------------------------------------------------- 1 | # deque objects are like double-ended queues 2 | 3 | import collections 4 | import string 5 | 6 | 7 | def main(): 8 | # initialize a deque with lowercase letters 9 | d = collections.deque(string.ascii_lowercase) 10 | 11 | # deques support the len() function 12 | print("Anzahl der Elemente: " + str(len(d))) 13 | 14 | # deques can be iterated over 15 | for elem in d: 16 | print(elem.upper(), end=",") 17 | 18 | # manipulate items from either end 19 | d.pop() 20 | d.popleft() 21 | d.append(2) 22 | d.appendleft(1) 23 | print(d) 24 | 25 | # rotate the deque 26 | print(d) 27 | d.rotate(1) 28 | print(d) 29 | 30 | 31 | if __name__ == "__main__": 32 | main() 33 | -------------------------------------------------------------------------------- /04 Collections/deque_start.py: -------------------------------------------------------------------------------- 1 | # deque objects are like double-ended queues 2 | 3 | import collections 4 | import string 5 | 6 | 7 | def main(): 8 | 9 | # TODO: initialize a deque with lowercase letters 10 | 11 | # TODO: deques support the len() function 12 | 13 | # TODO: deques can be iterated over 14 | 15 | # TODO: manipulate items from either end 16 | 17 | # TODO: rotate the deque 18 | 19 | 20 | if __name__ == "__main__": 21 | main() 22 | -------------------------------------------------------------------------------- /04 Collections/namedtup_finished.py: -------------------------------------------------------------------------------- 1 | # Demonstrate the usage of namdtuple objects 2 | 3 | import collections 4 | 5 | 6 | def main(): 7 | # create a Point namedtuple 8 | Point = collections.namedtuple("Point", "x y") 9 | 10 | p1 = Point(10, 20) 11 | p2 = Point(30, 40) 12 | 13 | print(p1, p2) 14 | print(p1.x, p1.y) 15 | 16 | # use _replace to create a new instance 17 | p1 = p1._replace(x=100) 18 | print(p1) 19 | 20 | 21 | if __name__ == "__main__": 22 | main() 23 | -------------------------------------------------------------------------------- /04 Collections/namedtup_start.py: -------------------------------------------------------------------------------- 1 | # Demonstrate the usage of namdtuple objects 2 | 3 | import collections 4 | 5 | 6 | def main(): 7 | # TODO: create a Point namedtuple 8 | 9 | # TODO: use _replace to create a new instance 10 | pass 11 | 12 | 13 | if __name__ == "__main__": 14 | main() 15 | -------------------------------------------------------------------------------- /04 Collections/ordereddict_finished.py: -------------------------------------------------------------------------------- 1 | # Demonstrate the usage of OrderedDict objects 2 | 3 | from collections import OrderedDict 4 | 5 | 6 | def main(): 7 | # list of sport teams with wins and losses 8 | sportTeams = [("Royals", (18, 12)), ("Rockets", (24, 6)), 9 | ("Cardinals", (20, 10)), ("Dragons", (22, 8)), 10 | ("Kings", (15, 15)), ("Chargers", (20, 10)), 11 | ("Jets", (16, 14)), ("Warriors", (25, 5))] 12 | 13 | # sort the teams by number of wins 14 | sortedTeams = sorted(sportTeams, key=lambda t: t[1][0], reverse=True) 15 | 16 | # create an ordered dictionary of the teams 17 | teams = OrderedDict(sortedTeams) 18 | print(teams) 19 | 20 | # Use popitem to remove the top item 21 | tm, wl = teams.popitem(False) 22 | print("Top team: ", tm, wl) 23 | 24 | # What are next the top 4 teams? 25 | for i, team in enumerate(teams, start=1): 26 | print(i, team) 27 | if i == 4: 28 | break 29 | 30 | # test for equality 31 | a = OrderedDict({"a": 1, "b": 2, "c": 3}) 32 | b = OrderedDict({"a": 1, "c": 3, "b": 2}) 33 | print("Test Gleichheit", a == b) 34 | 35 | 36 | if __name__ == "__main__": 37 | main() 38 | -------------------------------------------------------------------------------- /04 Collections/ordereddict_start.py: -------------------------------------------------------------------------------- 1 | # Demonstrate the usage of OrderedDict objects 2 | 3 | from collections import OrderedDict 4 | 5 | 6 | def main(): 7 | # list of sport teams with wins and losses 8 | sportTeams = [("Royals", (18, 12)), ("Rockets", (24, 6)), 9 | ("Cardinals", (20, 10)), ("Dragons", (22, 8)), 10 | ("Kings", (15, 15)), ("Chargers", (20, 10)), 11 | ("Jets", (16, 14)), ("Warriors", (25, 5))] 12 | 13 | # sort the teams by number of wins 14 | sortedTeams = sorted(sportTeams, key=lambda t: t[1][0], reverse=True) 15 | 16 | # TODO: create an ordered dictionary of the teams 17 | 18 | # TODO: Use popitem to remove the top item 19 | 20 | # TODO: What are next the top 4 teams? 21 | 22 | # TODO: test for equality 23 | 24 | if __name__ == "__main__": 25 | main() 26 | -------------------------------------------------------------------------------- /05 Classes/comparison_finished.py: -------------------------------------------------------------------------------- 1 | # Use special methods to compare objects to each other 2 | 3 | 4 | class Employee(): 5 | def __init__(self, fname, lname, level, yrsService): 6 | self.fname = fname 7 | self.lname = lname 8 | self.level = level 9 | self.seniority = yrsService 10 | 11 | # implement comparison functions by emp level 12 | def __ge__(self, other): 13 | if self.level == other.level: 14 | return self.seniority >= other.seniority 15 | return self.level >= other.level 16 | 17 | def __gt__(self, other): 18 | if self.level == other.level: 19 | return self.seniority > other.seniority 20 | return self.level > other.level 21 | 22 | def __lt__(self, other): 23 | if self.level == other.level: 24 | return self.seniority < other.seniority 25 | return self.level < other.level 26 | 27 | def __le__(self, other): 28 | if self.level == other.level: 29 | return self.seniority <= other.seniority 30 | return self.level <= other.level 31 | 32 | def __eq__(self, other): 33 | return self.level == other.level 34 | 35 | 36 | def main(): 37 | # define some employees 38 | dept = [] 39 | dept.append(Employee("Tim", "Sims", 5, 9)) 40 | dept.append(Employee("John", "Doe", 4, 12)) 41 | dept.append(Employee("Jane", "Smith", 6, 6)) 42 | dept.append(Employee("Rebecca", "Robinson", 5, 13)) 43 | dept.append(Employee("Tyler", "Durden", 5, 12)) 44 | 45 | # Who's more senior? 46 | print(bool(dept[0] > dept[2])) 47 | print(bool(dept[4] < dept[3])) 48 | 49 | # sort the items 50 | emps = sorted(dept) 51 | for emp in emps: 52 | print(emp.lname) 53 | 54 | 55 | if __name__ == "__main__": 56 | main() 57 | -------------------------------------------------------------------------------- /05 Classes/comparison_start.py: -------------------------------------------------------------------------------- 1 | # Use special methods to compare objects to each other 2 | 3 | 4 | class Employee(): 5 | def __init__(self, fname, lname, level, yrsService): 6 | self.fname = fname 7 | self.lname = lname 8 | self.level = level 9 | self.seniority = yrsService 10 | 11 | # TODO: implement comparison functions by emp level 12 | def __ge__(self, other): 13 | pass 14 | 15 | def __gt__(self, other): 16 | pass 17 | 18 | def __lt__(self, other): 19 | pass 20 | 21 | def __le__(self, other): 22 | pass 23 | 24 | def __eq__(self, other): 25 | pass 26 | 27 | 28 | def main(): 29 | # define some employees 30 | dept = [] 31 | dept.append(Employee("Tim", "Sims", 5, 9)) 32 | dept.append(Employee("John", "Doe", 4, 12)) 33 | dept.append(Employee("Jane", "Smith", 6, 6)) 34 | dept.append(Employee("Rebecca", "Robinson", 5, 13)) 35 | dept.append(Employee("Tyler", "Durden", 5, 12)) 36 | 37 | # TODO: Who's more senior? 38 | 39 | # TODO: sort the items 40 | 41 | 42 | if __name__ == "__main__": 43 | main() 44 | -------------------------------------------------------------------------------- /05 Classes/compattrs_finished.py: -------------------------------------------------------------------------------- 1 | # customize string representations of objects 2 | 3 | 4 | class myColor(): 5 | def __init__(self): 6 | self.red = 50 7 | self.green = 75 8 | self.blue = 100 9 | 10 | # use getattr to dynamically return a value 11 | def __getattr__(self, attr): 12 | if attr == "rgbcolor": 13 | return (self.red, self.green, self.blue) 14 | elif attr == "hexcolor": 15 | return "#{0:02x}{1:02x}{2:02x}".format(self.red, self.green, self.blue) 16 | else: 17 | raise AttributeError 18 | 19 | # use setattr to dynamically return a value 20 | def __setattr__(self, attr, val): 21 | if attr == "rgbcolor": 22 | self.red = val[0] 23 | self.green = val[1] 24 | self.blue = val[2] 25 | else: 26 | super().__setattr__(attr, val) 27 | 28 | # use dir to list the available properties 29 | def __dir__(self): 30 | return ("rgbolor", "hexcolor") 31 | 32 | 33 | def main(): 34 | # create an instance of myColor 35 | cls1 = myColor() 36 | # print the value of a computed attribute 37 | print(cls1.rgbcolor) 38 | print(cls1.hexcolor) 39 | 40 | # set the value of a computed attribute 41 | cls1.rgbcolor = (125, 200, 86) 42 | print(cls1.rgbcolor) 43 | print(cls1.hexcolor) 44 | 45 | # access a regular attribute 46 | print(cls1.red) 47 | 48 | # list the available attributes 49 | print(dir(cls1)) 50 | 51 | 52 | if __name__ == "__main__": 53 | main() 54 | -------------------------------------------------------------------------------- /05 Classes/compattrs_start.py: -------------------------------------------------------------------------------- 1 | # customize string representations of objects 2 | 3 | 4 | class myColor(): 5 | def __init__(self): 6 | self.red = 50 7 | self.green = 75 8 | self.blue = 100 9 | 10 | # TODO: use getattr to dynamically return a value 11 | 12 | 13 | # TODO: use setattr to dynamically return a value 14 | def __setattr__(self, attr, val): 15 | super().__setattr__(attr, val) 16 | 17 | # TODO: use dir to list the available properties 18 | 19 | 20 | def main(): 21 | # create an instance of myColor 22 | cls1 = myColor() 23 | # print the value of a computed attribute 24 | 25 | # set the value of a computed attribute 26 | 27 | # access a regular attribute 28 | 29 | # list the available attributes 30 | 31 | 32 | if __name__ == "__main__": 33 | main() 34 | -------------------------------------------------------------------------------- /05 Classes/enums_finished.py: -------------------------------------------------------------------------------- 1 | # define enumerations using the Enum base class 2 | 3 | from enum import Enum, unique, auto 4 | 5 | 6 | @unique 7 | class Fruit(Enum): 8 | APPLE = 1 9 | BANANA = 2 10 | ORANGE = 3 11 | TOMATO = 4 12 | PEAR = auto() 13 | 14 | 15 | def main(): 16 | # enums have human-readable values and types 17 | print(Fruit.APPLE) 18 | print(type(Fruit.APPLE)) 19 | print(repr(Fruit.APPLE)) 20 | 21 | # enums have name and value properties 22 | print(Fruit.APPLE.name, Fruit.APPLE.value) 23 | 24 | # print the auto-generated value 25 | print(Fruit.PEAR.value) 26 | 27 | # enums are hashable - can be used as keys 28 | myFruits = {} 29 | myFruits[Fruit.BANANA] = "Come Mr. Tally-man" 30 | print(myFruits[Fruit.BANANA]) 31 | 32 | 33 | if __name__ == "__main__": 34 | main() 35 | -------------------------------------------------------------------------------- /05 Classes/enums_start.py: -------------------------------------------------------------------------------- 1 | # define enumerations using the Enum base class 2 | from enum import Enum, unique, auto 3 | 4 | 5 | 6 | def main(): 7 | pass 8 | 9 | # TODO: enums have name and value properties 10 | 11 | # TODO: print the auto-generated value 12 | 13 | 14 | # TODO: enums are hashable - can be used as keys 15 | 16 | 17 | 18 | if __name__ == "__main__": 19 | main() 20 | -------------------------------------------------------------------------------- /05 Classes/numeric_finished.py: -------------------------------------------------------------------------------- 1 | # give objects number-like behavior 2 | 3 | 4 | class Point(): 5 | def __init__(self, x, y): 6 | self.x = x 7 | self.y = y 8 | 9 | def __repr__(self): 10 | return "".format(self.x, self.y) 11 | 12 | # implement addition 13 | def __add__(self, other): 14 | return Point(self.x + other.x, self.y + other.y) 15 | 16 | # implement subtraction 17 | def __sub__(self, other): 18 | return Point(self.x - other.x, self.y - other.y) 19 | 20 | # implement in-place addition 21 | def __iadd__(self, other): 22 | self.x += other.x 23 | self.y += other.y 24 | return self 25 | 26 | 27 | def main(): 28 | # Declare some points 29 | p1 = Point(10, 20) 30 | p2 = Point(30, 30) 31 | print(p1, p2) 32 | 33 | # Add two points 34 | p3 = p1 + p2 35 | print(p3) 36 | 37 | # subtract two points 38 | p4 = p2 - p1 39 | print(p4) 40 | 41 | # Perform in-place addition 42 | p1 += p2 43 | print(p1) 44 | 45 | 46 | if __name__ == "__main__": 47 | main() 48 | -------------------------------------------------------------------------------- /05 Classes/numeric_finished_warning.py: -------------------------------------------------------------------------------- 1 | # give objects number-like behavior 2 | 3 | 4 | class Int(): 5 | def __init__(self, x): 6 | self.x = x 7 | 8 | def __repr__(self): 9 | return "x:{0}".format(self.x) 10 | 11 | # implement addition 12 | def __add__(self, other): 13 | return Int(self.x + 2 * other.x) 14 | 15 | 16 | def main(): 17 | x = Int(10) 18 | y = Int(5) 19 | print("Wert von x:", x, "Wert von y", y) 20 | 21 | erg = x + y 22 | print("Wert von x + y:", erg) 23 | 24 | 25 | if __name__ == "__main__": 26 | main() 27 | -------------------------------------------------------------------------------- /05 Classes/numeric_start.py: -------------------------------------------------------------------------------- 1 | # give objects number-like behavior 2 | 3 | 4 | class Point(): 5 | def __init__(self, x, y): 6 | self.x = x 7 | self.y = y 8 | 9 | def __repr__(self): 10 | return "".format(self.x, self.y) 11 | 12 | # TODO: implement addition 13 | def __add__(self, other): 14 | pass 15 | 16 | # TODO: implement subtraction 17 | def __sub__(self, other): 18 | pass 19 | 20 | # TODO: implement in-place addition 21 | def __iadd__(self, other): 22 | pass 23 | 24 | 25 | def main(): 26 | # Declare some points 27 | p1 = Point(10, 20) 28 | p2 = Point(30, 30) 29 | print(p1, p2) 30 | 31 | # TODO: Add two points 32 | 33 | # TODO: subtract two points 34 | 35 | # TODO: Perform in-place addition 36 | 37 | 38 | if __name__ == "__main__": 39 | main() 40 | -------------------------------------------------------------------------------- /05 Classes/objectstrs_finished.py: -------------------------------------------------------------------------------- 1 | # customize string representations of objects 2 | 3 | 4 | class Person(): 5 | def __init__(self): 6 | self.fname = "Joe" 7 | self.lname = "Marini" 8 | self.age = 25 9 | 10 | # use __repr__ to create a string useful for debugging 11 | def __repr__(self): 12 | return "".format(self.fname, self.lname, self.age) 13 | 14 | # use str for a more human-readable string 15 | def __str__(self): 16 | return "Person ({0} {1} is {2})".format(self.fname, self.lname, self.age) 17 | 18 | # use bytes to convert the informal string to a bytes object 19 | def __bytes__(self): 20 | val = "Person:{0}:{1}:{2}".format(self.fname, self.lname, self.age) 21 | return bytes(val.encode('utf-8')) 22 | 23 | 24 | def main(): 25 | # create a new Person object 26 | cls1 = Person() 27 | 28 | # use different Python functions to convert it to a string 29 | print(repr(cls1)) 30 | print(str(cls1)) 31 | print("Formatted: {0}".format(cls1)) 32 | print(bytes(cls1)) 33 | 34 | 35 | if __name__ == "__main__": 36 | main() 37 | -------------------------------------------------------------------------------- /05 Classes/objectstrs_start.py: -------------------------------------------------------------------------------- 1 | # customize string representations of objects 2 | 3 | 4 | class Person(): 5 | def __init__(self): 6 | self.fname = "Joe" 7 | self.lname = "Marini" 8 | self.age = 25 9 | 10 | # TODO: use __repr__ to create a string useful for debugging 11 | 12 | # TODO: use str for a more human-readable string 13 | 14 | 15 | def main(): 16 | # create a new Person object 17 | cls1 = Person() 18 | 19 | # use different Python functions to convert it to a string 20 | print(repr(cls1)) 21 | print(str(cls1)) 22 | print("Formatted: {0}".format(cls1)) 23 | 24 | 25 | if __name__ == "__main__": 26 | main() 27 | -------------------------------------------------------------------------------- /06 Logging/basiclog_finished.py: -------------------------------------------------------------------------------- 1 | # demonstrate the logging api in Python 2 | 3 | # use the built-in logging module 4 | import logging 5 | 6 | 7 | def main(): 8 | # Use basicConfig to configure logging 9 | # this is only executed once, subsequent calls to 10 | # basicConfig will have no effect 11 | logging.basicConfig(level=logging.DEBUG, 12 | filemode="w", 13 | filename="output.log") 14 | 15 | # Try out each of the log levels 16 | logging.debug("Das ist eine Debug-Nachricht") 17 | logging.info("Das ist eine Info-Nachricht") 18 | logging.warning("Das ist eine Warning-Nachricht") 19 | logging.error("Das ist eine Error-Nachricht") 20 | logging.critical("Das ist eine Critical-Nachricht") 21 | 22 | # Output formatted string to the log 23 | logging.info("Hier ist eine {} Variable und ein int: {}".format("string", 10)) 24 | 25 | 26 | if __name__ == "__main__": 27 | main() 28 | -------------------------------------------------------------------------------- /06 Logging/basiclog_start.py: -------------------------------------------------------------------------------- 1 | # demonstrate the logging api in Python 2 | 3 | # TODO: use the built-in logging module 4 | 5 | def main(): 6 | # TODO: Use basicConfig to configure logging 7 | 8 | # Try out each of the log levels 9 | logging.debug("Das ist eine Debug-Nachricht") 10 | logging.info("Das ist eine Info-Nachricht") 11 | logging.warning("Das ist eine Warning-Nachricht") 12 | logging.error("Das ist eine Error-Nachricht") 13 | logging.critical("Das ist eine Critical-Nachricht") 14 | 15 | # TODO: Output formatted strings to the log 16 | 17 | 18 | if __name__ == "__main__": 19 | main() 20 | -------------------------------------------------------------------------------- /06 Logging/customlog_finished.py: -------------------------------------------------------------------------------- 1 | # Demonstrate how to customize logging output 2 | 3 | import logging 4 | 5 | extData = {'user':'Ralph'} 6 | # TODO: add another function to log from 7 | def meineProtokollFunktion(): 8 | logging.debug("Das ist eine Debug-Level-Nachricht",extra=extData) 9 | 10 | def main(): 11 | # set the output file and debug level, and 12 | # TODO: use a custom formatting specification 13 | fmtStr = "%(asctime)s: %(levelname)s: %(funcName)s Zeile:%(lineno)d User:%(user)s %(message)s" 14 | dateStr = "%m/%d/%Y %I:%M:%S %p" 15 | logging.basicConfig(filename="output.log", 16 | level=logging.DEBUG, format=fmtStr, datefmt=dateStr) 17 | 18 | logging.info("Das ist eine Info-Level-Nachricht", extra=extData) 19 | logging.warning("Das ist eine Warning-Level-Nachricht",extra=extData) 20 | meineProtokollFunktion() 21 | 22 | 23 | if __name__ == "__main__": 24 | main() 25 | -------------------------------------------------------------------------------- /06 Logging/customlog_start.py: -------------------------------------------------------------------------------- 1 | # Demonstrate how to customize logging output 2 | 3 | import logging 4 | 5 | # TODO: add another function to log from 6 | 7 | def main(): 8 | # set the output file and debug level, and 9 | # TODO: use a custom formatting specification 10 | logging.basicConfig(filename="output.log", 11 | level=logging.DEBUG) 12 | 13 | logging.info("Das ist eine info-Level-Nachricht") 14 | logging.warning("Das ist eine Warning-Level-Nachricht") 15 | 16 | 17 | if __name__ == "__main__": 18 | main() 19 | -------------------------------------------------------------------------------- /07 Comprehensions/dictcomp_finished.py: -------------------------------------------------------------------------------- 1 | # Demonstrate how to use dictionary comprehensions 2 | 3 | 4 | def main(): 5 | # define a list of temperature values 6 | ctemps = [0, 12, 34, 100] 7 | 8 | # Use a comprehension to build a dictionary 9 | tempDict = {t: (t * 9/5) + 32 for t in ctemps if t < 100} 10 | print(tempDict) 11 | print(tempDict[12]) 12 | 13 | # Merge two dictionaries with a comprehension 14 | team1 = {"Jones": 24, "Jameson": 18, "Smith": 58, "Burns": 7} 15 | team2 = {"White": 12, "Macke": 88, "Perce": 4} 16 | newTeam = {k: v for team in (team1, team2) for k, v in team.items()} 17 | print(newTeam) 18 | 19 | 20 | if __name__ == "__main__": 21 | main() 22 | -------------------------------------------------------------------------------- /07 Comprehensions/dictcomp_start.py: -------------------------------------------------------------------------------- 1 | # Demonstrate how to use dictionary comprehensions 2 | 3 | 4 | def main(): 5 | # define a list of temperature values 6 | ctemps = [0, 12, 34, 100] 7 | 8 | # TODO: Use a comprehension to build a dictionary 9 | 10 | # TODO: Merge two dictionaries with a comprehension 11 | team1 = {"Jones": 24, "Jameson": 18, "Smith": 58, "Burns": 7} 12 | team2 = {"White": 12, "Macke": 88, "Perce": 4} 13 | 14 | 15 | if __name__ == "__main__": 16 | main() 17 | -------------------------------------------------------------------------------- /07 Comprehensions/listcomp_finished.py: -------------------------------------------------------------------------------- 1 | # Demonstrate how to use list comprehensions 2 | 3 | 4 | def main(): 5 | # define two lists of numbers 6 | evens = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20] 7 | odds = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19] 8 | 9 | # Perform a mapping and filter function on a list 10 | evenSquared = list( 11 | map(lambda e: e**2, filter(lambda e: e > 4 and e < 16, evens))) 12 | print(evenSquared) 13 | 14 | # Derive a new list of numbers frm a given list 15 | evenSquared = [e ** 2 for e in evens] 16 | print(evenSquared) 17 | 18 | # Limit the items operated on with a predicate condition 19 | oddSquared = [e ** 2 for e in odds if e > 3 and e < 17] 20 | print(oddSquared) 21 | 22 | 23 | if __name__ == "__main__": 24 | main() 25 | -------------------------------------------------------------------------------- /07 Comprehensions/listcomp_start.py: -------------------------------------------------------------------------------- 1 | # Demonstrate how to use list comprehensions 2 | 3 | 4 | def main(): 5 | # define two lists of numbers 6 | evens = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20] 7 | odds = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19] 8 | 9 | # TODO: Perform a mapping and filter function on a list 10 | 11 | # TODO: Derive a new list of numbers frm a given list 12 | 13 | # TODO: Limit the items operated on with a predicate condition 14 | 15 | 16 | if __name__ == "__main__": 17 | main() 18 | -------------------------------------------------------------------------------- /07 Comprehensions/setcomp_finished.py: -------------------------------------------------------------------------------- 1 | # Demonstrate how to use set comprehensions 2 | 3 | 4 | def main(): 5 | # define a list of temperature data points 6 | ctemps = [5, 10, 12, 14, 10, 23, 41, 30, 12, 24, 12, 18, 29] 7 | 8 | # build a set of unique Fahrenheit temperatures 9 | ftemps1 = [(t * 9/5) + 32 for t in ctemps] 10 | ftemps2 = {(t * 9/5) + 32 for t in ctemps} 11 | print(ftemps1) 12 | print(ftemps2) 13 | 14 | # build a set from an input source 15 | sTemp = "The quick brown fox jumped over the lazy dog" 16 | chars = {c.upper() for c in sTemp if not c.isspace()} 17 | print(chars) 18 | 19 | 20 | if __name__ == "__main__": 21 | main() 22 | -------------------------------------------------------------------------------- /07 Comprehensions/setcomp_start.py: -------------------------------------------------------------------------------- 1 | # Demonstrate how to use set comprehensions 2 | 3 | 4 | def main(): 5 | # define a list of temperature data points 6 | ctemps = [5, 10, 12, 14, 10, 23, 41, 30, 12, 24, 12, 18, 29] 7 | 8 | # TODO: build a set of unique Fahrenheit temperatures 9 | 10 | # TODO: build a set from an input source 11 | 12 | if __name__ == "__main__": 13 | main() 14 | -------------------------------------------------------------------------------- /08 Pattern Matching/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace SwitchCase 8 | { 9 | class Program 10 | { 11 | static void Main(string[] args) 12 | { 13 | int a = 2; 14 | switch (a) 15 | { 16 | case 1: 17 | Console.WriteLine("Good morning"); 18 | break; 19 | case 3: { 20 | Console.WriteLine("Good day"); 21 | break; 22 | } 23 | case 2: 24 | Console.WriteLine("Good night"); 25 | break; 26 | default: Console.WriteLine("Default");break; 27 | } 28 | 29 | 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /08 Pattern Matching/SwitchCase1.java: -------------------------------------------------------------------------------- 1 | 2 | public class SwitchCase1 { 3 | 4 | public static void main(String[] args) { 5 | int a = 2; 6 | switch(a) { 7 | 8 | case 1: System.out.println("a");break; 9 | case 2: System.out.println("b");break; 10 | 11 | case 3: System.out.println("c");break; 12 | case 4: System.out.println("d");break; 13 | default: System.out.println("Default");break; 14 | } 15 | 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /08 Pattern Matching/SwitchCase1.js: -------------------------------------------------------------------------------- 1 | var a = prompt("Input number:"); 2 | switch(a){ 3 | case "3": console.log("Yes"); 4 | case 1: console.log("No"); 5 | case 42: console.log("Always"); 6 | default: console.log("Default"); 7 | } 8 | 9 | 10 | -------------------------------------------------------------------------------- /08 Pattern Matching/SwitchCase2.java: -------------------------------------------------------------------------------- 1 | 2 | public class SwitchCase2 { 3 | 4 | public static void main(String[] args) { 5 | String a = "2"; 6 | switch(a) { 7 | 8 | case "1": System.out.println("a");break; 9 | case "2": System.out.println("b");break; 10 | 11 | case "3": System.out.println("c");break; 12 | case "4": System.out.println("d");break; 13 | default: System.out.println("Default");break; 14 | } 15 | 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /08 Pattern Matching/SwitchCase2.js: -------------------------------------------------------------------------------- 1 | // No default 2 | var mon = prompt("Input Month:"); 3 | switch(mon){ 4 | case "Feb": console.log("Month with 28/29 days."); 5 | case "Apr": 6 | case "Jun": 7 | case "Sep": 8 | case "Nov": console.log("Month with 30 days."); 9 | default: console.log("Month with 31 days."); 10 | 11 | } 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /08 Pattern Matching/capture_finished.py: -------------------------------------------------------------------------------- 1 | # Capture pattern matching for assigning values within the match 2 | 3 | name = input("What is your name? ") 4 | 5 | match name: 6 | case "": 7 | print("Hello, anonymous!") 8 | case "Ralph" | "Ralf" as s: 9 | print(f"Oh hi there, {s}!") 10 | case name: 11 | print(f"Hello, {name}!") 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /08 Pattern Matching/capture_start.py: -------------------------------------------------------------------------------- 1 | # Capture pattern matching for assigning values within the match 2 | 3 | name = input("What is your name? ") 4 | 5 | -------------------------------------------------------------------------------- /08 Pattern Matching/class_finished.py: -------------------------------------------------------------------------------- 1 | # Objects pattern matching example - matches against object types 2 | 3 | # define some geometric shapes 4 | class Circle: 5 | def __init__(self, radius): 6 | self.radius = radius 7 | 8 | def getarea(self): 9 | return 3.14 * (self.radius ** 2) 10 | 11 | 12 | class Square: 13 | def __init__(self, side): 14 | self.side = side 15 | 16 | def getarea(self): 17 | return self.side * self.side 18 | 19 | 20 | class Rectangle: 21 | def __init__(self, width, height): 22 | self.width = width 23 | self.height = height 24 | 25 | def getarea(self): 26 | return self.width * self.height 27 | 28 | 29 | # create a list of some shapes 30 | shapes = [Circle(5), Square(4), Rectangle(4, 6), 31 | Square(7), Circle(9), Rectangle(2, 5)] 32 | 33 | # use pattern matching to process each shape 34 | for shape in shapes: 35 | match shape: 36 | case Circle(): 37 | print(f"Circle with area {shape.getarea()}") 38 | case Square(): 39 | print(f"Square with area {shape.getarea()}") 40 | case Rectangle(): 41 | print(f"Rectangle with area {shape.getarea()}") 42 | case _: 43 | print(f"Unrecognized shape: {type(shape)}") 44 | 45 | -------------------------------------------------------------------------------- /08 Pattern Matching/class_start.py: -------------------------------------------------------------------------------- 1 | # Objects pattern matching example - matches against object types 2 | 3 | # define some geometric shapes 4 | class Circle: 5 | def __init__(self, radius): 6 | self.radius = radius 7 | 8 | def getarea(self): 9 | return 3.14 * (self.radius ** 2) 10 | 11 | 12 | class Square: 13 | def __init__(self, side): 14 | self.side = side 15 | 16 | def getarea(self): 17 | return self.side * self.side 18 | 19 | 20 | class Rectangle: 21 | def __init__(self, width, height): 22 | self.width = width 23 | self.height = height 24 | 25 | def getarea(self): 26 | return self.width * self.height 27 | 28 | 29 | # create a list of some shapes 30 | shapes = [Circle(5), Square(4), Rectangle(4, 6), 31 | Square(7), Circle(9), Rectangle(2, 5)] 32 | 33 | # TODO: use pattern matching to process each shape 34 | -------------------------------------------------------------------------------- /08 Pattern Matching/guards1_finished.py: -------------------------------------------------------------------------------- 1 | # Using pattern guards to restrict how matches are made 2 | 3 | # define some geometric shapes 4 | class Circle: 5 | def __init__(self, radius): 6 | self.radius = radius 7 | 8 | def getarea(self): 9 | return 3.14 * (self.radius ** 2) 10 | 11 | 12 | class Square: 13 | def __init__(self, side): 14 | self.side = side 15 | 16 | def getarea(self): 17 | return self.side * self.side 18 | 19 | 20 | class Rectangle: 21 | def __init__(self, width, height): 22 | self.width = width 23 | self.height = height 24 | 25 | def getarea(self): 26 | return self.width * self.height 27 | 28 | 29 | # create a list of some shapes 30 | shapes = [Circle(5), Square(4), Rectangle(4, 6), 31 | Square(7), Circle(9), Rectangle(2, 5), 32 | Rectangle(9, 9)] 33 | 34 | # use pattern matching to process each shape 35 | # include pattern guards for more detailed processing 36 | for shape in shapes: 37 | match shape: 38 | case Circle(radius=r) if r >= 6: 39 | print(f"Large Circle with area {shape.getarea()}") 40 | case Circle(): 41 | print(f"Circle with area {shape.getarea()}") 42 | 43 | case Square(): 44 | print(f"Square with area {shape.getarea()}") 45 | case Rectangle(width=w, height=h) if w == h: 46 | print(f"Square Rectangle with area {shape.getarea()}") 47 | case Rectangle(): 48 | print(f"Rectangle with area {shape.getarea()}") 49 | case _: 50 | print(f"Unrecognized shape: {type(shape)}") 51 | 52 | -------------------------------------------------------------------------------- /08 Pattern Matching/guards1_start.py: -------------------------------------------------------------------------------- 1 | # Example file for Advanced Python: Language Features by Joe Marini 2 | # Using pattern guards to restrict how matches are made 3 | 4 | # define some geometric shapes 5 | class Circle: 6 | def __init__(self, radius): 7 | self.radius = radius 8 | 9 | def getarea(self): 10 | return 3.14 * (self.radius ** 2) 11 | 12 | 13 | class Square: 14 | def __init__(self, side): 15 | self.side = side 16 | 17 | def getarea(self): 18 | return self.side * self.side 19 | 20 | 21 | class Rectangle: 22 | def __init__(self, width, height): 23 | self.width = width 24 | self.height = height 25 | 26 | def getarea(self): 27 | return self.width * self.height 28 | 29 | 30 | # create a list of some shapes 31 | shapes = [Circle(5), Square(4), Rectangle(4, 6), 32 | Square(7), Circle(9), Rectangle(2, 5), 33 | Rectangle(9, 9)] 34 | 35 | # use pattern matching to process each shape 36 | # include pattern guards for more detailed processing 37 | for shape in shapes: 38 | match shape: 39 | # TODO: add a pattern guard for Circle 40 | 41 | case Circle(): 42 | print(f"Circle with area {shape.getarea()}") 43 | case Square(): 44 | print(f"Square with area {shape.getarea()}") 45 | case Rectangle(): 46 | print(f"Rectangle with area {shape.getarea()}") 47 | case _: 48 | print(f"Unrecognized shape: {type(shape)}") 49 | -------------------------------------------------------------------------------- /08 Pattern Matching/guards2_finished.py: -------------------------------------------------------------------------------- 1 | # Using pattern guards to restrict how matches are made 2 | 3 | # Pattern guards can get fairly sophisticated 4 | dataset = ["UPPER", 5, "Mixed Case", True, None] 5 | for d in dataset: 6 | match d: 7 | case str() as s if s.isupper(): 8 | print(f"{d}: Upper case string") 9 | case str(): 10 | print(f"{d}: Not an upper-case string") 11 | # order is important here - Python will treat bools as ints 12 | # so the check for bool has to come before int 13 | 14 | case bool(): 15 | print(f"{d}: Boolean") 16 | case int(): 17 | print(f"{d}: Integer") 18 | case _: 19 | print(f"{d}: Something else") 20 | -------------------------------------------------------------------------------- /08 Pattern Matching/guards2_start.py: -------------------------------------------------------------------------------- 1 | # Using pattern guards to restrict how matches are made 2 | 3 | # TODO: Pattern guards can get fairly sophisticated 4 | dataset = ["UPPER", 5, "Mixed Case", True, None] 5 | for d in dataset: 6 | match d: 7 | case _: 8 | print(f"{d}: Something else") 9 | -------------------------------------------------------------------------------- /08 Pattern Matching/sequence_finished.py: -------------------------------------------------------------------------------- 1 | # Sequence pattern matching example - matches against value sequences 2 | 3 | import math 4 | 5 | 6 | # Set up some test data with different math operations 7 | operations = [ 8 | ["Add", 1, 2, 3, 4, 5], 9 | ["Mul", 5, 6], 10 | ["Add", 10, 20], 11 | ["Sqrt", 9], 12 | ] 13 | 14 | result = 0 15 | 16 | # process each operation along with the set of given numbers 17 | for op in operations: 18 | match op: 19 | case "Mul", num1,num2: 20 | result = num1 * num2 21 | case "Sqrt", num: 22 | result = math.sqrt(num) 23 | case "Add",num1,*nums: 24 | result = num1 + sum(nums) 25 | case _: 26 | continue 27 | 28 | print(f"{op}: {result}") 29 | -------------------------------------------------------------------------------- /08 Pattern Matching/sequence_start.py: -------------------------------------------------------------------------------- 1 | # Sequence pattern matching example - matches against value sequences 2 | 3 | import math 4 | 5 | 6 | # Set up some test data with different math operations 7 | operations = [ 8 | ["Add", 1, 2, 3, 4, 5], 9 | ["Mul", 5, 6], 10 | ["Add", 10, 20], 11 | ["Sqrt", 9], 12 | ] 13 | 14 | result = 0 15 | 16 | # TODO: process each operation along with the set of given numbers 17 | for op in operations: 18 | match op: 19 | case _: 20 | continue 21 | 22 | print(f"{op}: {result}") 23 | -------------------------------------------------------------------------------- /08 Pattern Matching/simple_finished.py: -------------------------------------------------------------------------------- 1 | 2 | x = 8 3 | 4 | # Literal patterns are explicit values like integers, strings, Booleans, etc 5 | match x: 6 | case 0: 7 | print("Zero") 8 | case 1: 9 | print("One") 10 | case "Zero": 11 | print(0) 12 | case None: 13 | print("Nothing") 14 | case _: 15 | print("No match") 16 | -------------------------------------------------------------------------------- /08 Pattern Matching/simple_start.py: -------------------------------------------------------------------------------- 1 | x = 0 2 | 3 | # TODO: Literal patterns are explicit values: integers, strings, Booleans, etc 4 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | 2 | Contribution Agreement 3 | ====================== 4 | 5 | This repository does not accept pull requests (PRs). All pull requests will be closed. 6 | 7 | However, if any contributions (through pull requests, issues, feedback or otherwise) are provided, as a contributor, you represent that the code you submit is your original work or that of your employer (in which case you represent you have the right to bind your employer). By submitting code (or otherwise providing feedback), you (and, if applicable, your employer) are licensing the submitted code (and/or feedback) to LinkedIn and the open source community subject to the BSD 2-Clause license. 8 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | LinkedIn Learning Exercise Files License Agreement 2 | ================================================== 3 | 4 | This License Agreement (the "Agreement") is a binding legal agreement 5 | between you (as an individual or entity, as applicable) and LinkedIn 6 | Corporation (“LinkedIn”). By downloading or using the LinkedIn Learning 7 | exercise files in this repository (“Licensed Materials”), you agree to 8 | be bound by the terms of this Agreement. If you do not agree to these 9 | terms, do not download or use the Licensed Materials. 10 | 11 | 1. License. 12 | - a. Subject to the terms of this Agreement, LinkedIn hereby grants LinkedIn 13 | members during their LinkedIn Learning subscription a non-exclusive, 14 | non-transferable copyright license, for internal use only, to 1) make a 15 | reasonable number of copies of the Licensed Materials, and 2) make 16 | derivative works of the Licensed Materials for the sole purpose of 17 | practicing skills taught in LinkedIn Learning courses. 18 | - b. Distribution. Unless otherwise noted in the Licensed Materials, subject 19 | to the terms of this Agreement, LinkedIn hereby grants LinkedIn members 20 | with a LinkedIn Learning subscription a non-exclusive, non-transferable 21 | copyright license to distribute the Licensed Materials, except the 22 | Licensed Materials may not be included in any product or service (or 23 | otherwise used) to instruct or educate others. 24 | 25 | 2. Restrictions and Intellectual Property. 26 | - a. You may not to use, modify, copy, make derivative works of, publish, 27 | distribute, rent, lease, sell, sublicense, assign or otherwise transfer the 28 | Licensed Materials, except as expressly set forth above in Section 1. 29 | - b. Linkedin (and its licensors) retains its intellectual property rights 30 | in the Licensed Materials. Except as expressly set forth in Section 1, 31 | LinkedIn grants no licenses. 32 | - c. You indemnify LinkedIn and its licensors and affiliates for i) any 33 | alleged infringement or misappropriation of any intellectual property rights 34 | of any third party based on modifications you make to the Licensed Materials, 35 | ii) any claims arising from your use or distribution of all or part of the 36 | Licensed Materials and iii) a breach of this Agreement. You will defend, hold 37 | harmless, and indemnify LinkedIn and its affiliates (and our and their 38 | respective employees, shareholders, and directors) from any claim or action 39 | brought by a third party, including all damages, liabilities, costs and 40 | expenses, including reasonable attorneys’ fees, to the extent resulting from, 41 | alleged to have resulted from, or in connection with: (a) your breach of your 42 | obligations herein; or (b) your use or distribution of any Licensed Materials. 43 | 44 | 3. Open source. This code may include open source software, which may be 45 | subject to other license terms as provided in the files. 46 | 47 | 4. Warranty Disclaimer. LINKEDIN PROVIDES THE LICENSED MATERIALS ON AN “AS IS” 48 | AND “AS AVAILABLE” BASIS. LINKEDIN MAKES NO REPRESENTATION OR WARRANTY, 49 | WHETHER EXPRESS OR IMPLIED, ABOUT THE LICENSED MATERIALS, INCLUDING ANY 50 | REPRESENTATION THAT THE LICENSED MATERIALS WILL BE FREE OF ERRORS, BUGS OR 51 | INTERRUPTIONS, OR THAT THE LICENSED MATERIALS ARE ACCURATE, COMPLETE OR 52 | OTHERWISE VALID. TO THE FULLEST EXTENT PERMITTED BY LAW, LINKEDIN AND ITS 53 | AFFILIATES DISCLAIM ANY IMPLIED OR STATUTORY WARRANTY OR CONDITION, INCLUDING 54 | ANY IMPLIED WARRANTY OR CONDITION OF MERCHANTABILITY OR FITNESS FOR A 55 | PARTICULAR PURPOSE, AVAILABILITY, SECURITY, TITLE AND/OR NON-INFRINGEMENT. 56 | YOUR USE OF THE LICENSED MATERIALS IS AT YOUR OWN DISCRETION AND RISK, AND 57 | YOU WILL BE SOLELY RESPONSIBLE FOR ANY DAMAGE THAT RESULTS FROM USE OF THE 58 | LICENSED MATERIALS TO YOUR COMPUTER SYSTEM OR LOSS OF DATA. NO ADVICE OR 59 | INFORMATION, WHETHER ORAL OR WRITTEN, OBTAINED BY YOU FROM US OR THROUGH OR 60 | FROM THE LICENSED MATERIALS WILL CREATE ANY WARRANTY OR CONDITION NOT 61 | EXPRESSLY STATED IN THESE TERMS. 62 | 63 | 5. Limitation of Liability. LINKEDIN SHALL NOT BE LIABLE FOR ANY INDIRECT, 64 | INCIDENTAL, SPECIAL, PUNITIVE, CONSEQUENTIAL OR EXEMPLARY DAMAGES, INCLUDING 65 | BUT NOT LIMITED TO, DAMAGES FOR LOSS OF PROFITS, GOODWILL, USE, DATA OR OTHER 66 | INTANGIBLE LOSSES . IN NO EVENT WILL LINKEDIN'S AGGREGATE LIABILITY TO YOU 67 | EXCEED $100. THIS LIMITATION OF LIABILITY SHALL: 68 | - i. APPLY REGARDLESS OF WHETHER (A) YOU BASE YOUR CLAIM ON CONTRACT, TORT, 69 | STATUTE, OR ANY OTHER LEGAL THEORY, (B) WE KNEW OR SHOULD HAVE KNOWN ABOUT 70 | THE POSSIBILITY OF SUCH DAMAGES, OR (C) THE LIMITED REMEDIES PROVIDED IN THIS 71 | SECTION FAIL OF THEIR ESSENTIAL PURPOSE; AND 72 | - ii. NOT APPLY TO ANY DAMAGE THAT LINKEDIN MAY CAUSE YOU INTENTIONALLY OR 73 | KNOWINGLY IN VIOLATION OF THESE TERMS OR APPLICABLE LAW, OR AS OTHERWISE 74 | MANDATED BY APPLICABLE LAW THAT CANNOT BE DISCLAIMED IN THESE TERMS. 75 | 76 | 6. Termination. This Agreement automatically terminates upon your breach of 77 | this Agreement or termination of your LinkedIn Learning subscription. On 78 | termination, all licenses granted under this Agreement will terminate 79 | immediately and you will delete the Licensed Materials. Sections 2-7 of this 80 | Agreement survive any termination of this Agreement. LinkedIn may discontinue 81 | the availability of some or all of the Licensed Materials at any time for any 82 | reason. 83 | 84 | 7. Miscellaneous. This Agreement will be governed by and construed in 85 | accordance with the laws of the State of California without regard to conflict 86 | of laws principles. The exclusive forum for any disputes arising out of or 87 | relating to this Agreement shall be an appropriate federal or state court 88 | sitting in the County of Santa Clara, State of California. If LinkedIn does 89 | not act to enforce a breach of this Agreement, that does not mean that 90 | LinkedIn has waived its right to enforce this Agreement. The Agreement does 91 | not create a partnership, agency relationship, or joint venture between the 92 | parties. Neither party has the power or authority to bind the other or to 93 | create any obligation or responsibility on behalf of the other. You may not, 94 | without LinkedIn’s prior written consent, assign or delegate any rights or 95 | obligations under these terms, including in connection with a change of 96 | control. Any purported assignment and delegation shall be ineffective. The 97 | Agreement shall bind and inure to the benefit of the parties, their respective 98 | successors and permitted assigns. If any provision of the Agreement is 99 | unenforceable, that provision will be modified to render it enforceable to the 100 | extent possible to give effect to the parties’ intentions and the remaining 101 | provisions will not be affected. This Agreement is the only agreement between 102 | you and LinkedIn regarding the Licensed Materials, and supersedes all prior 103 | agreements relating to the Licensed Materials. 104 | 105 | Last Updated: March 2019 106 | -------------------------------------------------------------------------------- /NOTICE: -------------------------------------------------------------------------------- 1 | Copyright 2022 LinkedIn Corporation 2 | All Rights Reserved. 3 | 4 | Licensed under the LinkedIn Learning Exercise File License (the "License"). 5 | See LICENSE in the project root for license information. 6 | 7 | Please note, this project may automatically load third party code from external 8 | repositories (for example, NPM modules, Composer packages, or other dependencies). 9 | If so, such third party code may be subject to other license terms than as set 10 | forth above. In addition, such third party code may also depend on and load 11 | multiple tiers of dependencies. Please review the applicable licenses of the 12 | additional dependencies. 13 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Python für Fortgeschrittene 2 | Dies ist das Repository für den **LinkedIn Learning**-Kurs "Python für Fortgeschrittene". Der vollständige Kurs ist bei [LinkedIn Learning](https://de.linkedin.com/learning/python-fur-fortgeschrittene) verfügbar. 3 | 4 | ![COURSENAME][lil-thumbnail-url] 5 | 6 | ## Über diesen Kurs 7 | Dieses Video-Training richtet sich an Python-Entwickler, die tiefer in die mächtige Programmiersprache einsteigen und seine Leistungsfähigkeit und Flexibilität voll ausnutzen wollen. Unter anderen lernen Sie, wie Sie die integrierten Funktionen von Python einsetzen, um Daten effektiv zu bearbeiten, wie Sie benutzerdefinierte Klassen und Funktionen erstellen oder auch, wie Sie Ihren Code eleganter schreiben, damit er einfacher zu lesen und zu warten ist. Sehen Sie auch, wie Sie Ihren Code und Projekte von Python 2 auf Python 3 portieren können. 8 | 9 | ## Anleitung 10 | Die Quellcodes zu dem Kurs sind nach Kapiteln strukturiert. In jedem der Ordner für ein Kapitel sind die Quellcodedateien zu dem jeweiligen Kapitel des Kurses zu finden. 11 | 12 | 13 | ## Installation/Download 14 | 1. Um diese Übungsdateien zu verwenden, müssen Sie diese nur als Dateien downloaden. 15 | 2. Alternativ klonen Sie dieses Repository auf Ihren lokalen Rechner mit dem Terminal (Mac), CMD (Windows) oder einem GUI-Tool wie SourceTree. 16 | 17 | ## Über den Autor - Ralph Steyer 18 | Sie finden [weitere Kurse von Ralph Steyer](https://www.linkedin.com/learning/instructors/ralph-steyer) auf **LinkedIn Learning**. Folgen Sie ihm auf [LinkedIn](https://www.linkedin.com/in/ralph-steyer-a69781/?trk=lil_instructor). 19 | 20 | [lil-thumbnail-url]: https://cdn.lynda.com/course/2996438/2996438-1603182786066-16x9.jpg 21 | --------------------------------------------------------------------------------