├── .github ├── CODEOWNERS ├── PULL_REQUEST_TEMPLATE.md ├── workflows │ └── main.yml └── ISSUE_TEMPLATE.md ├── Start ├── Ch_5 │ ├── simple_start.py │ ├── capture_start.py │ ├── sequence_start.py │ ├── class_start.py │ ├── challenge_start.py │ └── guards_start.py ├── Ch_2 │ ├── docstrings_start.py │ ├── varargs_start.py │ ├── keyargs_start.py │ ├── lambdas_start.py │ └── challenge_start.py ├── Ch_4 │ ├── enums_start.py │ ├── objectstrs_start.py │ ├── numeric_start.py │ ├── compattrs_start.py │ ├── comparison_start.py │ └── challenge_start.py ├── Ch_3 │ ├── challenge_start.py │ ├── dictcomp_start.py │ ├── listcomp_start.py │ └── setcomp_start.py └── Ch_1 │ ├── templstr_start.py │ ├── strings_start.py │ └── assign_start.py ├── Finished ├── Ch_5 │ ├── capture_finished.py │ ├── simple_finished.py │ ├── sequence_finished.py │ ├── class_finished.py │ ├── guards_finished.py │ └── challenge_finished.py ├── Ch_2 │ ├── keyargs_finished.py │ ├── docstrings_finished.py │ ├── varargs_finished.py │ ├── lambdas_finished.py │ └── challenge_finished.py ├── Ch_3 │ ├── setcomp_finished.py │ ├── dictcomp_finished.py │ ├── listcomp_finished.py │ └── challenge_finished.py ├── Ch_1 │ ├── strings_finished.py │ ├── templstr_finished.py │ ├── codingstyle_finished.py │ └── assign_finished.py └── Ch_4 │ ├── enums_finished.py │ ├── numeric_finished.py │ ├── objectstrs_finished.py │ ├── compattrs_finished.py │ ├── comparison_finished.py │ └── challenge_finished.py ├── CONTRIBUTING.md ├── NOTICE ├── .vscode └── settings.json ├── .devcontainer ├── devcontainer.json └── Dockerfile ├── README.md ├── .gitignore └── LICENSE /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | # Codeowners for these exercise files: 2 | # * (asterisk) denotes "all files and folders" 3 | # Example: * @producer @instructor 4 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Start/Ch_5/simple_start.py: -------------------------------------------------------------------------------- 1 | # Example file for Advanced Python: Language Features by Joe Marini 2 | # Simple pattern matching using literal values 3 | 4 | x = 0 5 | 6 | # TODO: Literal patterns are explicit values: integers, strings, Booleans, etc 7 | -------------------------------------------------------------------------------- /Start/Ch_2/docstrings_start.py: -------------------------------------------------------------------------------- 1 | # Example file for Advanced Python: Language Features by Joe Marini 2 | # Demonstrate the use of lambda functions 3 | 4 | 5 | def my_function(arg1, arg2=None): 6 | print(arg1, arg2) 7 | 8 | 9 | print(my_function.__doc__) 10 | -------------------------------------------------------------------------------- /Start/Ch_5/capture_start.py: -------------------------------------------------------------------------------- 1 | # Example file for Advanced Python: Language Features by Joe Marini 2 | # Capture pattern matching for assigning values within the match 3 | 4 | name = input("What is your name? ") 5 | 6 | match name: 7 | case "": 8 | print("Hello, anonymous!") 9 | -------------------------------------------------------------------------------- /Start/Ch_2/varargs_start.py: -------------------------------------------------------------------------------- 1 | # Example file for Advanced Python: Language Features by Joe Marini 2 | # Demonstrate the use of lambda functions 3 | 4 | 5 | # TODO: define a function that takes variable arguments 6 | def addition(): 7 | pass 8 | 9 | 10 | # TODO: pass different arguments 11 | print(addition()) 12 | 13 | # TODO: pass an existing list 14 | -------------------------------------------------------------------------------- /Start/Ch_2/keyargs_start.py: -------------------------------------------------------------------------------- 1 | # Example file for Advanced Python: Language Features by Joe Marini 2 | # Demonstrate the use of keyword-only arguments 3 | 4 | 5 | # use keyword-only arguments to help ensure code clarity 6 | def MyFunction(): 7 | pass 8 | 9 | 10 | # try to call the function without the keyword 11 | # myFunction(1, 2, True) 12 | MyFunction() 13 | -------------------------------------------------------------------------------- /Start/Ch_4/enums_start.py: -------------------------------------------------------------------------------- 1 | # Example file for Advanced Python: Language Features by Joe Marini 2 | # define enumerations using the Enum base class 3 | 4 | 5 | # TODO: enums have human-readable values and types 6 | 7 | # TODO: enums have name and value properties 8 | 9 | # TODO: print the auto-generated value 10 | 11 | # TODO: enums are hashable - can be used as keys 12 | -------------------------------------------------------------------------------- /Start/Ch_3/challenge_start.py: -------------------------------------------------------------------------------- 1 | # Example file for Advanced Python: Language Features by Joe Marini 2 | # Programming challenge for comprehensions 3 | 4 | import string 5 | import pprint 6 | 7 | 8 | test_str = "2 apples, 9 oranges?, 4 pears, Mike's 1 egg, Jane's 2 kiwis, $50!" 9 | 10 | # YOUR CODE HERE 11 | 12 | # print the data 13 | str_data = { 14 | } 15 | pprint.pp(str_data) 16 | -------------------------------------------------------------------------------- /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | name: Copy To Branches 2 | on: 3 | workflow_dispatch: 4 | jobs: 5 | copy-to-branches: 6 | runs-on: ubuntu-latest 7 | steps: 8 | - uses: actions/checkout@v2 9 | with: 10 | fetch-depth: 0 11 | - name: Copy To Branches Action 12 | uses: planetoftheweb/copy-to-branches@v1.2 13 | env: 14 | key: main 15 | -------------------------------------------------------------------------------- /Finished/Ch_5/capture_finished.py: -------------------------------------------------------------------------------- 1 | # Example file for Advanced Python: Language Features by Joe Marini 2 | # Capture pattern matching for assigning values within the match 3 | 4 | name = input("What is your name? ") 5 | 6 | match name: 7 | case "": 8 | print("Hello, anonymous!") 9 | case "Joe" | "Joseph" as s: 10 | print(f"Oh hi there, {s}!") 11 | case name: 12 | print(f"Hello, {name}!") 13 | -------------------------------------------------------------------------------- /Finished/Ch_2/keyargs_finished.py: -------------------------------------------------------------------------------- 1 | # Example file for Advanced Python: Language Features by Joe Marini 2 | # Demonstrate the use of keyword-only arguments 3 | 4 | 5 | # use keyword-only arguments to help ensure code clarity 6 | def my_function(arg1, arg2, *, suppressExceptions=False): 7 | print(arg1, arg2, suppressExceptions) 8 | 9 | 10 | # try to call the function without the keyword 11 | # myFunction(1, 2, True) 12 | my_function(1, 2, suppressExceptions=True) 13 | -------------------------------------------------------------------------------- /Start/Ch_3/dictcomp_start.py: -------------------------------------------------------------------------------- 1 | # Example file for Advanced Python: Language Features by Joe Marini 2 | # Demonstrate how to use dictionary comprehensions 3 | 4 | 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 | -------------------------------------------------------------------------------- /Start/Ch_3/listcomp_start.py: -------------------------------------------------------------------------------- 1 | # Example file for Advanced Python: Language Features by Joe Marini 2 | # Demonstrate how to use list comprehensions 3 | 4 | 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 | -------------------------------------------------------------------------------- /Finished/Ch_5/simple_finished.py: -------------------------------------------------------------------------------- 1 | # Example file for Advanced Python: Language Features by Joe Marini 2 | # Simple pattern matching using literal values 3 | 4 | x = 0 5 | 6 | # Literal patterns are explicit values like integers, strings, Booleans, etc 7 | match x: 8 | case 0: 9 | print("Zero") 10 | case 1: 11 | print("One") 12 | case "Zero": 13 | print(0) 14 | case None: 15 | print("Nothing") 16 | case _: 17 | print("No match") 18 | -------------------------------------------------------------------------------- /Start/Ch_2/lambdas_start.py: -------------------------------------------------------------------------------- 1 | # Example file for Advanced Python: Language Features by Joe Marini 2 | # Use lambdas as in-place functions 3 | 4 | 5 | def celsisus_to_fahrenheit(temp): 6 | return (temp * 9/5) + 32 7 | 8 | 9 | def fahrenheit_to_celsisus(temp): 10 | return (temp-32) * 5/9 11 | 12 | 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 | -------------------------------------------------------------------------------- /Start/Ch_3/setcomp_start.py: -------------------------------------------------------------------------------- 1 | # Example file for Advanced Python: Language Features by Joe Marini 2 | # Demonstrate how to use set comprehensions 3 | 4 | 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 | ftemps1 = [(t * 9/5) + 32 for t in ctemps] 10 | print(ftemps1) 11 | 12 | # TODO: build a set from an input source 13 | s_temp = "The quick brown fox jumped over the lazy dog" 14 | -------------------------------------------------------------------------------- /Start/Ch_1/templstr_start.py: -------------------------------------------------------------------------------- 1 | # Example file for Advanced Python: Language Features by Joe Marini 2 | # demonstrate template string functions 3 | 4 | 5 | # Usual string formatting with f-strings 6 | str1 = "Advanced Python: Language Features" 7 | str2 = "Joe Marini" 8 | outputstr = f"You're watching {str1} by {str2}" 9 | print(outputstr) 10 | 11 | # TODO: create a template with placeholders 12 | 13 | # TODO: use the substitute method with keyword arguments 14 | 15 | # TODO: use the substitute method with a dictionary 16 | -------------------------------------------------------------------------------- /Finished/Ch_2/docstrings_finished.py: -------------------------------------------------------------------------------- 1 | # Example file for Advanced Python: Language Features by Joe Marini 2 | # Demonstrate the use of lambda functions 3 | 4 | 5 | def my_function(arg1, arg2=None): 6 | """my_function(arg1, arg2=None) --> Doesn't really do anything special. 7 | 8 | Parameters: 9 | arg1: the first argument. Whatever you feel like passing. 10 | arg2: the second argument. Defaults to None. Whatever makes you happy. 11 | """ 12 | print(arg1, arg2) 13 | 14 | 15 | print(my_function.__doc__) 16 | -------------------------------------------------------------------------------- /Finished/Ch_2/varargs_finished.py: -------------------------------------------------------------------------------- 1 | # Example file for Advanced Python: Language Features by Joe Marini 2 | # Demonstrate the use of lambda functions 3 | 4 | 5 | # define a function that takes variable arguments 6 | def addition(*args): 7 | result = 0 8 | for arg in args: 9 | result += arg 10 | 11 | return result 12 | 13 | 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 | -------------------------------------------------------------------------------- /Start/Ch_1/strings_start.py: -------------------------------------------------------------------------------- 1 | # Example file for Advanced Python: Language Features by Joe Marini 2 | # strings and bytes are not directly interchangeable 3 | # strings contain unicode, bytes are raw 8-bit values 4 | 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 | -------------------------------------------------------------------------------- /Start/Ch_5/sequence_start.py: -------------------------------------------------------------------------------- 1 | # Example file for Advanced Python: Language Features by Joe Marini 2 | # Sequence pattern matching example - matches against value sequences 3 | 4 | import math 5 | 6 | 7 | # Set up some test data with different math operations 8 | operations = [ 9 | ["Add", 1, 2, 3, 4, 5], 10 | ["Mul", 5, 6], 11 | ["Add", 10, 20], 12 | ["Sqrt", 9], 13 | ] 14 | 15 | result = 0 16 | 17 | # TODO: process each operation along with the set of given numbers 18 | for op in operations: 19 | match op: 20 | case _: 21 | continue 22 | 23 | print(f"{op}: {result}") 24 | -------------------------------------------------------------------------------- /Finished/Ch_3/setcomp_finished.py: -------------------------------------------------------------------------------- 1 | # Example file for Advanced Python: Language Features by Joe Marini 2 | # Demonstrate how to use set comprehensions 3 | 4 | 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 | print(ftemps1) 11 | ftemps2 = {(t * 9/5) + 32 for t in ctemps} 12 | print(ftemps2) 13 | 14 | # build a set from an input source 15 | s_temp = "The quick brown fox jumped over the lazy dog" 16 | chars = {c.upper() for c in s_temp if not c.isspace()} 17 | print(chars) 18 | -------------------------------------------------------------------------------- /Start/Ch_4/objectstrs_start.py: -------------------------------------------------------------------------------- 1 | # Example file for Advanced Python: Language Features by Joe Marini 2 | # customize string representations of objects 3 | 4 | 5 | class Person(): 6 | def __init__(self): 7 | self.fname = "Joe" 8 | self.lname = "Marini" 9 | self.age = 25 10 | 11 | # TODO: use __repr__ to create a string useful for debugging 12 | 13 | # TODO: use str for a more human-readable string 14 | 15 | 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(f"Formatted: {cls1}") 23 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /Finished/Ch_3/dictcomp_finished.py: -------------------------------------------------------------------------------- 1 | # Example file for Advanced Python: Language Features by Joe Marini 2 | # Demonstrate how to use dictionary comprehensions 3 | 4 | 5 | # define a list of temperature values 6 | ctemps = [0, 12, 34, 100] 7 | 8 | # Use a comprehension to build a dictionary 9 | temp_dict = {t: (t * 9/5) + 32 for t in ctemps if t < 100} 10 | print(temp_dict) 11 | print(temp_dict[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 | -------------------------------------------------------------------------------- /NOTICE: -------------------------------------------------------------------------------- 1 | Copyright 2023 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 | -------------------------------------------------------------------------------- /Finished/Ch_2/lambdas_finished.py: -------------------------------------------------------------------------------- 1 | # Example file for Advanced Python: Language Features by Joe Marini 2 | # Use lambdas as in-place functions 3 | 4 | 5 | def celsisus_to_fahrenheit(temp): 6 | return (temp * 9/5) + 32 7 | 8 | 9 | def fahrenheit_to_celsisus(temp): 10 | return (temp-32) * 5/9 11 | 12 | 13 | ctemps = [0, 12, 34, 100] 14 | ftemps = [32, 65, 100, 212] 15 | 16 | # Use regular functions to convert temps 17 | print(list(map(fahrenheit_to_celsisus, ftemps))) 18 | print(list(map(celsisus_to_fahrenheit, 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 | -------------------------------------------------------------------------------- /Start/Ch_1/assign_start.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 | # regular assignment statements assign a value 8 | x = 5 9 | print(x) 10 | 11 | # TODO: the assignment operator is part of an expression 12 | 13 | 14 | # TODO: The assignment expression is useful for writing concise code 15 | 16 | 17 | # TODO: The walrus operator can help reduce redundant function calls 18 | values = [12, 0, 10, 5, 9, 18, 41, 23, 30, 16, 18, 9, 18, 22] 19 | val_data = { 20 | "length": len(values), 21 | "total": sum(values), 22 | "average": sum(values) / len(values) 23 | } 24 | -------------------------------------------------------------------------------- /Finished/Ch_1/strings_finished.py: -------------------------------------------------------------------------------- 1 | # Example file for Advanced Python: Language Features by Joe Marini 2 | # strings and bytes are not directly interchangeable 3 | # strings contain unicode, bytes are raw 8-bit values 4 | 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 | -------------------------------------------------------------------------------- /Finished/Ch_3/listcomp_finished.py: -------------------------------------------------------------------------------- 1 | # Example file for Advanced Python: Language Features by Joe Marini 2 | # Demonstrate how to use list comprehensions 3 | 4 | 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 | -------------------------------------------------------------------------------- /Finished/Ch_4/enums_finished.py: -------------------------------------------------------------------------------- 1 | # Example file for Advanced Python: Language Features by Joe Marini 2 | # define enumerations using the Enum base class 3 | 4 | from enum import Enum, unique, auto 5 | 6 | 7 | @unique 8 | class Fruit(Enum): 9 | APPLE = 1 10 | BANANA = 2 11 | ORANGE = 3 12 | TOMATO = 4 13 | PEAR = auto() 14 | 15 | 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 | -------------------------------------------------------------------------------- /Finished/Ch_1/templstr_finished.py: -------------------------------------------------------------------------------- 1 | # Example file for Advanced Python: Language Features by Joe Marini 2 | # demonstrate template string functions 3 | 4 | from string import Template 5 | 6 | 7 | # Usual string formatting with format() 8 | str1 = "Advanced Python: Language Features" 9 | str2 = "Joe Marini" 10 | outputstr = f"You're watching {str1} by {str2}" 11 | print(outputstr) 12 | 13 | # create a template with placeholders 14 | templ = Template("You're watching ${title} by ${author}") 15 | 16 | # use the substitute method with keyword arguments 17 | str2 = templ.substitute(title="Advanced Python", author="Joe Marini") 18 | print(str2) 19 | 20 | # use the substitute method with a dictionary 21 | data = { 22 | "author": "Joe Marini", 23 | "title": "Advanced Python" 24 | } 25 | str3 = templ.substitute(data) 26 | print(str3) 27 | -------------------------------------------------------------------------------- /Finished/Ch_5/sequence_finished.py: -------------------------------------------------------------------------------- 1 | # Example file for Advanced Python: Language Features by Joe Marini 2 | # Sequence pattern matching example - matches against value sequences 3 | 4 | import math 5 | 6 | 7 | # Set up some test data with different math operations 8 | operations = [ 9 | ["Add", 1, 2, 3, 4, 5], 10 | ["Mul", 5, 6], 11 | ["Add", 10, 20], 12 | ["Sqrt", 9], 13 | ] 14 | 15 | result = 0 16 | 17 | # process each operation along with the set of given numbers 18 | for op in operations: 19 | match op: 20 | case "Add", num1, *nums: 21 | result = num1 + sum(nums) 22 | case "Mul", num1, num2: 23 | result = num1 * num2 24 | case "Sqrt", num: 25 | result = math.sqrt(num) 26 | case _: 27 | continue 28 | 29 | print(f"{op}: {result}") 30 | -------------------------------------------------------------------------------- /Start/Ch_4/numeric_start.py: -------------------------------------------------------------------------------- 1 | # Example file for Advanced Python: Language Features by Joe Marini 2 | # give objects number-like behavior 3 | 4 | 5 | class Point(): 6 | def __init__(self, x, y): 7 | self.x = x 8 | self.y = y 9 | 10 | def __repr__(self): 11 | return f"" 12 | 13 | # TODO: implement addition 14 | def __add__(self, other): 15 | pass 16 | 17 | # TODO: implement subtraction 18 | def __sub__(self, other): 19 | pass 20 | 21 | # TODO: implement in-place addition 22 | def __iadd__(self, other): 23 | pass 24 | 25 | 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 | -------------------------------------------------------------------------------- /Finished/Ch_1/codingstyle_finished.py: -------------------------------------------------------------------------------- 1 | # Example file for Advanced Python: Language Features by Joe Marini 2 | # Python coding style example file 3 | 4 | # imports go on their own lines 5 | import datetime 6 | import platform 7 | 8 | 9 | # two blank lines separate classes from other functions 10 | class MyClass(): 11 | def __init__(self): 12 | self.prop1 = "my class" 13 | self.now = datetime.datetime.now 14 | 15 | # within classes, one blank line separates methods 16 | def function_name(self, use_name): 17 | print(platform.version()) 18 | if use_name: 19 | print(platform.uname()) 20 | 21 | 22 | # Long comments, like this one that flow across several lines, are 23 | # limited to 72 characters instead of 79 for lines of code. 24 | cls1 = MyClass() 25 | cls1.prop1 = "hello world" 26 | cls1.function_name(True) 27 | -------------------------------------------------------------------------------- /Finished/Ch_3/challenge_finished.py: -------------------------------------------------------------------------------- 1 | # Example file for Advanced Python: Language Features by Joe Marini 2 | # Programming challenge for comprehensions 3 | 4 | import string 5 | import pprint 6 | 7 | 8 | test_str = "2 apples, 9 oranges?, 4 pears, Mike's 1 egg, Jane's 2 kiwis, $50!" 9 | 10 | # get the total length of the string 11 | l = len(test_str) 12 | 13 | # count the number characters 14 | nums = len([c for c in test_str if c.isnumeric()]) 15 | 16 | # count the punctuation characters 17 | punct = len([c for c in test_str if c in string.punctuation]) 18 | 19 | # use a set to count the unique letters 20 | unique = "".join({c for c in test_str if c.isalpha()}) 21 | 22 | # print the data 23 | str_data = { 24 | "Length:": l, 25 | "Digits:": nums, 26 | "Punctuation": punct, 27 | "Unique Letters": unique, 28 | "Unique Count": len(unique) 29 | } 30 | pprint.pp(str_data) 31 | -------------------------------------------------------------------------------- /Finished/Ch_1/assign_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 | # regular assignment statements assign a value 8 | x = 5 9 | print(x) 10 | 11 | # the assignment operator is part of an expression 12 | (x := 10) 13 | print(x) 14 | 15 | # The assignment expression is useful for writing concise code 16 | while (thestr := input("value? ")) != "exit": 17 | print(thestr) 18 | 19 | # The walrus operator can help reduce redundant function calls 20 | values = [12, 0, 10, 5, 9, 18, 41, 23, 30, 16, 18, 9, 18, 22] 21 | val_data = { 22 | "length": (l := len(values)), 23 | "total": (s := sum(values)), 24 | "average": s / l 25 | } 26 | pprint.pp(val_data) 27 | 28 | # if any((item := value) % 2 == 1 for value in values): 29 | # print(f"First odd number: {item}") 30 | -------------------------------------------------------------------------------- /Start/Ch_4/compattrs_start.py: -------------------------------------------------------------------------------- 1 | # Example file for Advanced Python: Language Features by Joe Marini 2 | # customize string representations of objects 3 | 4 | 5 | class MyColor(): 6 | def __init__(self): 7 | self.red = 50 8 | self.green = 75 9 | self.blue = 100 10 | 11 | # TODO: use getattr to dynamically return a value 12 | # def __getattr__(self, attr): 13 | # pass 14 | 15 | # TODO: use setattr to dynamically return a value 16 | # def __setattr__(self, attr, val): 17 | # pass 18 | 19 | # TODO: use dir to list the available properties 20 | # def __dir__(self): 21 | # pass 22 | 23 | 24 | # create an instance of myColor 25 | cls1 = MyColor() 26 | # TODO: print the value of a computed attribute 27 | 28 | # TODO: set the value of a computed attribute 29 | 30 | # TODO: access a regular attribute 31 | 32 | # TODO: list the available attributes 33 | -------------------------------------------------------------------------------- /Start/Ch_5/class_start.py: -------------------------------------------------------------------------------- 1 | # Example file for Advanced Python: Language Features by Joe Marini 2 | # Objects pattern matching example - matches against object types 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 | 34 | # TODO: use pattern matching to process each shape 35 | -------------------------------------------------------------------------------- /Finished/Ch_4/numeric_finished.py: -------------------------------------------------------------------------------- 1 | # Example file for Advanced Python: Language Features by Joe Marini 2 | # give objects number-like behavior 3 | 4 | 5 | class Point(): 6 | def __init__(self, x, y): 7 | self.x = x 8 | self.y = y 9 | 10 | def __repr__(self): 11 | return "".format(self.x, self.y) 12 | 13 | # implement addition 14 | def __add__(self, other): 15 | return Point(self.x + other.x, self.y + other.y) 16 | 17 | # implement subtraction 18 | def __sub__(self, other): 19 | return Point(self.x - other.x, self.y - other.y) 20 | 21 | # implement in-place addition 22 | def __iadd__(self, other): 23 | self.x += other.x 24 | self.y += other.y 25 | return self 26 | 27 | 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 | -------------------------------------------------------------------------------- /Finished/Ch_4/objectstrs_finished.py: -------------------------------------------------------------------------------- 1 | # Example file for Advanced Python: Language Features by Joe Marini 2 | # customize string representations of objects 3 | 4 | 5 | class Person(): 6 | def __init__(self): 7 | self.fname = "Joe" 8 | self.lname = "Marini" 9 | self.age = 25 10 | 11 | # use __repr__ to create a string useful for debugging 12 | def __repr__(self): 13 | return f"" 14 | 15 | # use str for a more human-readable string 16 | def __str__(self): 17 | return f"Person ({self.fname} {self.lname} is {self.age})" 18 | 19 | # use bytes to convert the informal string to a bytes object 20 | def __bytes__(self): 21 | val = f"Person:{self.fname}:{self.lname}:{self.age}" 22 | return bytes(val.encode('utf-8')) 23 | 24 | 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 | -------------------------------------------------------------------------------- /Start/Ch_4/comparison_start.py: -------------------------------------------------------------------------------- 1 | # Example file for Advanced Python: Language Features by Joe Marini 2 | # Use special methods to compare objects to each other 3 | 4 | 5 | class Employee(): 6 | def __init__(self, fname, lname, level, years_service): 7 | self.fname = fname 8 | self.lname = lname 9 | self.level = level 10 | self.seniority = years_service 11 | 12 | # TODO: implement comparison functions by emp level 13 | def __ge__(self, other): 14 | pass 15 | 16 | def __gt__(self, other): 17 | pass 18 | 19 | def __lt__(self, other): 20 | pass 21 | 22 | def __le__(self, other): 23 | pass 24 | 25 | def __eq__(self, other): 26 | pass 27 | 28 | 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 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "editor.bracketPairColorization.enabled": true, 3 | "editor.cursorBlinking": "solid", 4 | "editor.fontFamily": "ui-monospace, Menlo, Monaco, 'Cascadia Mono', 'Segoe UI Mono', 'Roboto Mono', 'Oxygen Mono', 'Ubuntu Monospace', 'Source Code Pro', 'Fira Mono', 'Droid Sans Mono', 'Courier New', monospace", 5 | "editor.fontLigatures": false, 6 | "editor.fontSize": 14, 7 | "editor.formatOnPaste": true, 8 | "editor.formatOnSave": true, 9 | "editor.lineNumbers": "on", 10 | "editor.matchBrackets": "always", 11 | "editor.minimap.enabled": false, 12 | "editor.smoothScrolling": true, 13 | "editor.tabSize": 4, 14 | "editor.useTabStops": true, 15 | "emmet.triggerExpansionOnTab": true, 16 | "explorer.openEditors.visible": 0, 17 | "files.autoSave": "afterDelay", 18 | "screencastMode.onlyKeyboardShortcuts": true, 19 | "terminal.integrated.fontSize": 22, 20 | "workbench.colorTheme": "Visual Studio Light", 21 | "workbench.fontAliasing": "antialiased", 22 | "workbench.statusBar.visible": true, 23 | "debug.console.fontSize": 22 24 | } 25 | -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /Start/Ch_2/challenge_start.py: -------------------------------------------------------------------------------- 1 | # Example file for Advanced Python: Language Features by Joe Marini 2 | # Challenge solution file for Advanced Functions 3 | 4 | # Challenge: 5 | # Write a function that performs the following actions: 6 | # 1: accepts a variable number of strings and numbers. Other types ignored 7 | # 2: accepts a keyword-only argument to return a unique-only result 8 | # 3: combines all the arguments into a single string 9 | # 4: returns a string containing all arguments combined as one string 10 | # 5: Has a docstring that explains how it works 11 | # If the unique-only argument is True (default False), then the result 12 | # combined string will not contain any duplicate characters 13 | 14 | 15 | def string_combiner(*args, unique=False): 16 | result = "" 17 | 18 | # YOUR CODE HERE 19 | 20 | return result 21 | 22 | 23 | # test code: 24 | print(string_combiner.__doc__) 25 | output = string_combiner("This", "is", 1, "test", "string!", unique=False) 26 | print(output) 27 | output = string_combiner("This", "is", 1, "test", "string!", unique=True) 28 | print(output) 29 | output = string_combiner("This", "is", 1, True, "string!", unique=False) 30 | print(output) 31 | output = string_combiner("This", "is", [1, 2], "string!", unique=False) 32 | print(output) 33 | -------------------------------------------------------------------------------- /.devcontainer/devcontainer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Python 3", 3 | "build": { 4 | "dockerfile": "Dockerfile", 5 | "context": "..", 6 | "args": { 7 | "VARIANT": "3.10", // Set Python version here 8 | "NODE_VERSION": "lts/*" 9 | } 10 | }, 11 | "settings": { 12 | "python.defaultInterpreterPath": "/usr/local/bin/python", 13 | "python.linting.enabled": true, 14 | "python.linting.pylintEnabled": true, 15 | "python.formatting.autopep8Path": "/usr/local/py-utils/bin/autopep8", 16 | "python.formatting.blackPath": "/usr/local/py-utils/bin/black", 17 | "python.formatting.yapfPath": "/usr/local/py-utils/bin/yapf", 18 | "python.linting.banditPath": "/usr/local/py-utils/bin/bandit", 19 | "python.linting.flake8Path": "/usr/local/py-utils/bin/flake8", 20 | "python.linting.mypyPath": "/usr/local/py-utils/bin/mypy", 21 | "python.linting.pycodestylePath": "/usr/local/py-utils/bin/pycodestyle", 22 | "python.linting.pydocstylePath": "/usr/local/py-utils/bin/pydocstyle", 23 | "python.linting.pylintPath": "/usr/local/py-utils/bin/pylint", 24 | "python.linting.pylintArgs": ["--disable=C0111"] 25 | }, 26 | "extensions": [ 27 | "ms-python.python", 28 | "ms-python.vscode-pylance" 29 | ], 30 | "remoteUser": "vscode", 31 | "onCreateCommand": "echo PS1='\"$ \"' >> ~/.bashrc" //Set Terminal Prompt to $ 32 | } 33 | -------------------------------------------------------------------------------- /Start/Ch_5/challenge_start.py: -------------------------------------------------------------------------------- 1 | # Example file for Advanced Python: Language Features by Joe Marini 2 | # Programming challenge for Structural Pattern Matching 3 | 4 | # Dry Clean: [garment, size, starch, same_day] 5 | # garments are shirt, pants, jacket, dress 6 | # each item is 12.95, plus 2.00 for starch 7 | # same day service adds 10.00 per same-day item 8 | # Wash and Fold: [description, weight] 9 | # 4.95 per pound, with 10% off if more than 15 pounds 10 | # Blankets: [type, dryclean, size] 11 | # type is "comforter" or "cover" 12 | # Flat fee of 25.00 13 | # --- 14 | # Output: 15 | # Order Total Price 16 | 17 | test_orders = [ 18 | [ 19 | ["shirt", "L", True, False], 20 | ["shirt", "M", True, False], 21 | ["shirt", "L", False, True], 22 | ["pants", "M", False, True], 23 | ["pants", "S", False, False], 24 | ["pants", "S", False, False], 25 | ["jacket", "M", False, False], 26 | ["jacket", "L", False, True] 27 | ], 28 | [ 29 | ["dress", "M", False, True], 30 | ["whites", 5.25], 31 | ["darks", 12.5] 32 | ], 33 | [ 34 | ["shirts and jeans", 28.0], 35 | ["comforter", False, "L"], 36 | ["cover", True, "L"], 37 | ["shirt", "L", True, True] 38 | ] 39 | ] 40 | 41 | # TODO: process each order 42 | -------------------------------------------------------------------------------- /Finished/Ch_5/class_finished.py: -------------------------------------------------------------------------------- 1 | # Example file for Advanced Python: Language Features by Joe Marini 2 | # Objects pattern matching example - matches against object types 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 | 34 | # use pattern matching to process each shape 35 | for shape in shapes: 36 | match shape: 37 | case Circle(): 38 | print(f"Circle with area {shape.getarea()}") 39 | case Square(): 40 | print(f"Square with area {shape.getarea()}") 41 | case Rectangle(): 42 | print(f"Rectangle with area {shape.getarea()}") 43 | case _: 44 | print(f"Unrecognized shape: {type(shape)}") 45 | -------------------------------------------------------------------------------- /.devcontainer/Dockerfile: -------------------------------------------------------------------------------- 1 | # See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.233.0/containers/python-3/.devcontainer/base.Dockerfile 2 | 3 | # [Choice] Python version (use -bullseye variants on local arm64/Apple Silicon): 3, 3.10, 3.9, 3.8, 3.7, 3.6, 3-bullseye, 3.10-bullseye, 3.9-bullseye, 3.8-bullseye, 3.7-bullseye, 3.6-bullseye, 3-buster, 3.10-buster, 3.9-buster, 3.8-buster, 3.7-buster, 3.6-buster 4 | ARG VARIANT="3.10" 5 | FROM mcr.microsoft.com/vscode/devcontainers/python:0-${VARIANT} 6 | 7 | # [Choice] Node.js version: none, lts/*, 16, 14, 12, 10 8 | ARG NODE_VERSION="none" 9 | RUN if [ "${NODE_VERSION}" != "none" ]; then su vscode -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi 10 | 11 | # [Optional] If your pip requirements rarely change, uncomment this section to add them to the image. 12 | # COPY requirements.txt /tmp/pip-tmp/ 13 | # RUN pip3 --disable-pip-version-check --no-cache-dir install -r /tmp/pip-tmp/requirements.txt \ 14 | # && rm -rf /tmp/pip-tmp 15 | 16 | # [Optional] Uncomment this section to install additional OS packages. 17 | # RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ 18 | # && apt-get -y install --no-install-recommends 19 | 20 | # [Optional] Uncomment this line to install global node packages. 21 | # RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g " 2>&1 22 | -------------------------------------------------------------------------------- /Finished/Ch_4/compattrs_finished.py: -------------------------------------------------------------------------------- 1 | # Example file for Advanced Python: Language Features by Joe Marini 2 | # customize string representations of objects 3 | 4 | 5 | class MyColor(): 6 | def __init__(self): 7 | self.red = 50 8 | self.green = 75 9 | self.blue = 100 10 | 11 | # use getattr to dynamically return a value 12 | def __getattr__(self, attr): 13 | if attr == "rgbcolor": 14 | return (self.red, self.green, self.blue) 15 | elif attr == "hexcolor": 16 | return f"#{self.red:02x}{self.green:02x}{self.blue:02x}" 17 | else: 18 | raise AttributeError(f"{attr} is not a valid attribute") 19 | 20 | # use setattr to dynamically return a value 21 | def __setattr__(self, attr, val): 22 | if attr == "rgbcolor": 23 | self.red = val[0] 24 | self.green = val[1] 25 | self.blue = val[2] 26 | else: 27 | super().__setattr__(attr, val) 28 | 29 | # use dir to list the available properties 30 | def __dir__(self): 31 | return ("rgbolor", "hexcolor") 32 | 33 | 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 | -------------------------------------------------------------------------------- /Start/Ch_5/guards_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 | 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 | # TODO: add a pattern guard for Circle 39 | 40 | case Circle(): 41 | print(f"Circle with area {shape.getarea()}") 42 | case Square(): 43 | print(f"Square with area {shape.getarea()}") 44 | case Rectangle(): 45 | print(f"Rectangle with area {shape.getarea()}") 46 | case _: 47 | print(f"Unrecognized shape: {type(shape)}") 48 | 49 | # TODO: Pattern guards can get fairly sophisticated 50 | dataset = ["UPPER", 5, "Mixed Case", True, None] 51 | # for d in dataset: 52 | # match d: 53 | # case _: 54 | # print(f"{d}: Something else") 55 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Advanced Python: Language Features 2 | This is the repository for the LinkedIn Learning course Advanced Python: Language Features. The full course is available from [LinkedIn Learning][lil-course-url]. 3 | 4 | ![Advanced Python: Language Features][lil-thumbnail-url] 5 | 6 | Python has become the language of choice of many developers for building all kinds of applications across a wide range of industries, but to fully take advantage of its power and flexibility, you need to master all its advanced functionality. Python is a flexible, customizable language that provides features that other languages support only through third-party libraries or require that you build yourself. In this course, Joe Marini takes you through some of the more advanced features of the Python language. Joe shows you how to write code that is easier to read and maintain, build classes that work just like the ones that are native to the language, and work with some of the newest features of the language itself, like structural pattern matching. 7 | If you're ready to take your Python skills to the next level, join Joe in this course. 8 | 9 | 10 | ## Instructor 11 | Joe Marini has been building software professionally for some of the biggest and best known companies in Silicon Valley for more than 30 years. 12 | 13 | 14 | Check out my other courses on [LinkedIn Learning](https://www.linkedin.com/learning/instructors/joe-marini). 15 | 16 | [lil-course-url]: https://www.linkedin.com/learning/advanced-python-language-features?dApp=59033956 17 | [lil-thumbnail-url]: https://media.licdn.com/dms/image/C560DAQGse5pGo4mLQw/learning-public-crop_288_512/0/1678465532457?e=2147483647&v=beta&t=0UQWPDRu2DI_YBrVq-s7L5jQ4WkpV6Xzr4aVR3tuPnM 18 | -------------------------------------------------------------------------------- /Finished/Ch_4/comparison_finished.py: -------------------------------------------------------------------------------- 1 | # Example file for Advanced Python: Language Features by Joe Marini 2 | # Use special methods to compare objects to each other 3 | 4 | 5 | class Employee(): 6 | def __init__(self, fname, lname, level, years_service): 7 | self.fname = fname 8 | self.lname = lname 9 | self.level = level 10 | self.seniority = years_service 11 | 12 | # implement comparison functions by emp level 13 | def __ge__(self, other): 14 | if self.level == other.level: 15 | return self.seniority >= other.seniority 16 | return self.level >= other.level 17 | 18 | def __gt__(self, other): 19 | if self.level == other.level: 20 | return self.seniority > other.seniority 21 | return self.level > other.level 22 | 23 | def __lt__(self, other): 24 | if self.level == other.level: 25 | return self.seniority < other.seniority 26 | return self.level < other.level 27 | 28 | def __le__(self, other): 29 | if self.level == other.level: 30 | return self.seniority <= other.seniority 31 | return self.level <= other.level 32 | 33 | def __eq__(self, other): 34 | return self.level == other.level 35 | 36 | 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 | -------------------------------------------------------------------------------- /Finished/Ch_2/challenge_finished.py: -------------------------------------------------------------------------------- 1 | # Example file for Advanced Python: Language Features by Joe Marini 2 | # Challenge solution file for Advanced Functions 3 | 4 | # Challenge: 5 | # Write a function that performs the following actions: 6 | # 1: accepts a variable number of strings and numbers. Other types ignored 7 | # 2: accepts a keyword-only argument to return a unique-only result 8 | # 3: combines all the arguments into a single string 9 | # 4: returns a string containing all arguments combined as one string 10 | # 5: Has a docstring that explains how it works 11 | # If the unique-only argument is True (default False), then the result 12 | # combined string will not contain any duplicate characters 13 | 14 | 15 | def string_combiner(*args, unique=False): 16 | """ 17 | string_combiner(*args, unique=False) 18 | Returns a string that merges all strings and ints in 'args'. 19 | Parameters: 20 | args: one or more strings and ints. Other types are ignored. 21 | unique: if True, the result string contains only 1 instance of each character 22 | """ 23 | result = "" 24 | for arg in args: 25 | if isinstance(arg, int): 26 | result += str(arg) 27 | elif isinstance(arg, str): 28 | result += arg 29 | 30 | # if unique is true, we need to convert to a set and then a string 31 | if unique: 32 | newresult = set(result) 33 | result = "".join(newresult) 34 | 35 | return result 36 | 37 | 38 | # test code: 39 | print(string_combiner.__doc__) 40 | output = string_combiner("This", "is", 1, "test", "string!", unique=False) 41 | print(output) 42 | output = string_combiner("This", "is", 1, "test", "string!", unique=True) 43 | print(output) 44 | output = string_combiner("This", "is", 1, True, "string!", unique=False) 45 | print(output) 46 | output = string_combiner("This", "is", [1, 2], "string!", unique=False) 47 | print(output) 48 | -------------------------------------------------------------------------------- /Finished/Ch_5/guards_finished.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 | case Circle(radius=r) if r >= 6: 40 | print(f"Large Circle with area {shape.getarea()}") 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(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 | # Pattern guards can get fairly sophisticated 53 | dataset = ["UPPER", 5, "Mixed Case", True, None] 54 | for d in dataset: 55 | match d: 56 | case str() as s if s.isupper(): 57 | print(f"{d}: Upper case string") 58 | case str(): 59 | print(f"{d}: Not an upper-case string") 60 | # order is important here - Python will treat bools as ints 61 | # so the check for bool has to come before int 62 | case bool(): 63 | print(f"{d}: Boolean") 64 | case int(): 65 | print(f"{d}: Integer") 66 | case _: 67 | print(f"{d}: Something else") 68 | -------------------------------------------------------------------------------- /Start/Ch_4/challenge_start.py: -------------------------------------------------------------------------------- 1 | # Example file for Advanced Python: Language Features by Joe Marini 2 | # Programming challenge for Special Class Methods 3 | 4 | 5 | # Challenge: 6 | # Given a class that represents a Book with various properties such 7 | # as title, author, pagecount, etc: 8 | # 1) Implement the __repr__ and __str__ functions to output: 9 | # str: "(title) by (author): (pagecount), (cover), (price)" 10 | # repr: "" 11 | # 2) Implement the comparison methods to allow comparing books based 12 | # on pagecount. 13 | # 3) Implement an enum that represents the type of the book cover. The 14 | # allowable cover types are "hard" and "paperback". Replace the existing 15 | # "Hard" and "paperback" strings with the enum. 16 | # 4) Implement an "adjustedprice" computed attribute - books that are antiques 17 | # have a 10.00 surcharge on their price, Paperback books get a 2.00 discount 18 | # 5) Successfully execute the sample code provided below. 19 | 20 | 21 | class Book(): 22 | def __init__(self, title, author, pages, cover, antique, price): 23 | self.title = title 24 | self.author = author 25 | self.pages = pages 26 | self.cover = cover 27 | self.antique = antique 28 | self.price = price 29 | 30 | # TODO: Implement the str and repr functions 31 | 32 | # TODO: Implement the adjustedprice attribute 33 | 34 | # TODO: Implement comparisons <, >, <=, >= 35 | 36 | 37 | # TODO: Implement the Hard/Paperback Enum 38 | 39 | 40 | books = [ 41 | Book("War and Peace", "Leo Tolstoy", 1225, "Hard", True, 29.95), 42 | Book("Brave New World", "Aldous Huxley", 311, "Paperback", True, 32.50), 43 | Book("Crime and Punishment", "Fyodor Dostoevsky", 492, "Hard", False, 19.75), 44 | Book("Moby Dick", "Herman Melville", 427, "Paperback", True, 22.95), 45 | Book("A Christmas Carol", "Charles Dickens", 66, "Hard", False, 31.95), 46 | Book("Animal Farm", "George Orwell", 130, "Paperback", False, 26.95), 47 | Book("Farenheit 451", "Ray Bradbury", 256, "Hard", True, 28.95), 48 | Book("Jane Eyre", "Charlotte Bronte", 536, "Paperback", False, 34.95) 49 | ] 50 | 51 | # TEST CODE 52 | 53 | # 1 - test the str and repr functions 54 | print("-------------") 55 | print(str(books[0])) 56 | print(str(books[3])) 57 | print(str(books[5])) 58 | print() 59 | print(repr(books[0])) 60 | print(repr(books[3])) 61 | print(repr(books[5])) 62 | print("-------------") 63 | 64 | # 2 - test the "adjustedprice" computed attribute 65 | for book in books: 66 | print(f"{book.title}: {book.adjustedprice:.2f}") 67 | print("-------------") 68 | print() 69 | 70 | # 3 - compare on pagecount 71 | print(books[1] > books[2]) 72 | print(books[4] < books[6]) 73 | print(books[7] >= books[0]) 74 | print(books[3] <= books[4]) 75 | -------------------------------------------------------------------------------- /Finished/Ch_5/challenge_finished.py: -------------------------------------------------------------------------------- 1 | # Example file for Advanced Python: Language Features by Joe Marini 2 | # Programming challenge for Structural Pattern Matching 3 | 4 | # Dry Clean: [garment, size, starch, same_day] 5 | # garments are shirt, pants, jacket, dress 6 | # each item is 12.95, plus 2.00 for starch 7 | # same day service adds 10.00 per same-day item 8 | # Wash and Fold: [description, weight] 9 | # 4.95 per pound, with 10% off if more than 15 pounds 10 | # Blankets: [type, dryclean, size] 11 | # type is "comforter" or "cover" 12 | # Flat fee of 25.00 13 | # --- 14 | # Output: 15 | # Order Total Price 16 | 17 | test_orders = [ 18 | [ 19 | ["shirt", "L", True, False], 20 | ["shirt", "M", True, False], 21 | ["shirt", "L", False, True], 22 | ["pants", "M", False, True], 23 | ["pants", "S", False, False], 24 | ["pants", "S", False, False], 25 | ["jacket", "M", False, False], 26 | ["jacket", "L", False, True] 27 | ], 28 | [ 29 | ["dress", "M", False, True], 30 | ["whites", 5.25], 31 | ["darks", 12.5] 32 | ], 33 | [ 34 | ["shirts and jeans", 28.0], 35 | ["comforter", False, "L"], 36 | ["cover", True, "L"], 37 | ["shirt", "L", True, True] 38 | ] 39 | ] 40 | 41 | # process each order 42 | for order in test_orders: 43 | # set the initial variables for the totals 44 | total_price = 0.0 45 | 46 | print("--------------") 47 | for item in order: 48 | match item: 49 | # use literal strings to make sure we match accepted garments 50 | case "shirt" | "pants" | "jacket" | "dress" as garment, size, starch, sameday: 51 | total_price += 12.95 52 | if starch: 53 | total_price += 2.00 54 | if sameday: 55 | total_price += 10.00 56 | print(f"Dry Clean:({size}) {garment}", "Starched" if starch else "", 57 | "same-day" if sameday else "") 58 | # for wash and fold, capture the desc and make sure it's a string 59 | case str() as desc, weight: 60 | if weight >= 15.0: 61 | total_price += (weight * 4.95) * .9 62 | else: 63 | total_price += (weight * 4.95) 64 | print(f"Wash/Fold: {desc}, weight: {weight:.1f}") 65 | # again, use literal strings to ensure correct type 66 | case "comforter" | "cover" as blanket, dry_clean, size: 67 | total_price += 25.00 68 | print(f"Blanket: ({size}) {blanket}", 69 | "Dry clean" if dry_clean else "") 70 | case _: 71 | print("invalid item format") 72 | 73 | print(f"Order total: {total_price:.2f}") 74 | print("--------------") 75 | -------------------------------------------------------------------------------- /Finished/Ch_4/challenge_finished.py: -------------------------------------------------------------------------------- 1 | # Example file for Advanced Python: Language Features by Joe Marini 2 | # Programming challenge for Special Class Methods 3 | from enum import Enum 4 | 5 | # Challenge: 6 | # Given a class that represents a Book with various properties such 7 | # as title, author, pagecount, etc: 8 | # 1) Implement the __repr__ and __str__ functions to output: 9 | # str: "(title) by (author): (pagecount), (cover), (price)" 10 | # repr: "" 11 | # 2) Implement the comparison methods to allow comparing books based 12 | # on pagecount. 13 | # 3) Implement an enum that represents the type of the book cover. The 14 | # allowable cover types are "hard" and "paperback". Replace the existing 15 | # "Hard" and "paperback" strings with the enum. 16 | # 4) Implement an "adjustedprice" computed attribute - books that are antiques 17 | # have a 10.00 surcharge on their price, Paperback books get a 2.00 discount 18 | # 5) Successfully execute the sample code provided below. 19 | 20 | 21 | class Book(): 22 | def __init__(self, title, author, pages, cover, antique, price): 23 | self.title = title 24 | self.author = author 25 | self.pages = pages 26 | self.cover = cover 27 | self.antique = antique 28 | self.price = price 29 | 30 | # TODO: Implement the str and repr functions 31 | def __str__(self) -> str: 32 | return f"{self.title} by {self.author}: {self.pages}, {self.cover}, {self.price}" 33 | 34 | def __repr__(self) -> str: 35 | return f"" 36 | 37 | # TODO: Implement the adjustedprice attribute 38 | def __getattr__(self, attr): 39 | if attr == "adjustedprice": 40 | val = self.price 41 | if self.antique == True: 42 | val += 10.0 43 | if self.cover == CoverType.PAPERBACK: 44 | val -= 2.0 45 | return val 46 | 47 | # TODO: Implement comparisons <, >, <=, >= 48 | def __ge__(self, other): 49 | return self.pages >= other.pages 50 | 51 | def __gt__(self, other): 52 | return self.pages > other.pages 53 | 54 | def __le__(self, other): 55 | return self.pages <= other.pages 56 | 57 | def __lt__(self, other): 58 | return self.pages < other.pages 59 | 60 | 61 | # TODO: Implement the Hard/Paperback Enum 62 | class CoverType(Enum): 63 | HARD = 0 64 | PAPERBACK = 1 65 | 66 | 67 | books = [ 68 | Book("War and Peace", "Leo Tolstoy", 1225, 69 | CoverType.HARD, True, 29.95), 70 | Book("Brave New World", "Aldous Huxley", 71 | 311, CoverType.PAPERBACK, True, 32.50), 72 | Book("Crime and Punishment", "Fyodor Dostoevsky", 73 | 492, CoverType.HARD, False, 19.75), 74 | Book("Moby Dick", "Herman Melville", 427, 75 | CoverType.PAPERBACK, True, 22.95), 76 | Book("A Christmas Carol", "Charles Dickens", 77 | 66, CoverType.HARD, False, 31.95), 78 | Book("Animal Farm", "George Orwell", 130, 79 | CoverType.PAPERBACK, False, 26.95), 80 | Book("Farenheit 451", "Ray Bradbury", 256, 81 | CoverType.HARD, True, 28.95), 82 | Book("Jane Eyre", "Charlotte Bronte", 536, 83 | CoverType.PAPERBACK, False, 34.95) 84 | ] 85 | 86 | # TEST CODE 87 | 88 | # 1 - test the str and repr functions 89 | print("-------------") 90 | print(str(books[0])) 91 | print(str(books[3])) 92 | print(str(books[5])) 93 | print() 94 | print(repr(books[0])) 95 | print(repr(books[3])) 96 | print(repr(books[5])) 97 | print("-------------") 98 | print() 99 | 100 | # 2 - test the "adjustedprice" computed attribute 101 | for book in books: 102 | print(f"{book.title}: {book.adjustedprice:.2f}") 103 | print("-------------") 104 | print() 105 | 106 | # 3 - compare on pagecount 107 | print(books[1] > books[2]) 108 | print(books[4] < books[6]) 109 | print(books[7] >= books[0]) 110 | print(books[3] <= books[4]) 111 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Apple 2 | *.DS_Store 3 | 4 | # Built application files 5 | *.apk 6 | *.ap_ 7 | 8 | # Files for the Dalvik VM 9 | *.dex 10 | 11 | # Java class files 12 | *.class 13 | 14 | # Generated files 15 | bin/ 16 | gen/ 17 | 18 | # Gradle files 19 | .gradle/ 20 | build/ 21 | 22 | # Local configuration file (sdk path, etc) 23 | local.properties 24 | 25 | # Proguard folder generated by Eclipse 26 | proguard/ 27 | 28 | # Log Files 29 | *.log 30 | 31 | # Android Studio Navigation editor temp files 32 | .navigation/ 33 | 34 | # Android Studio captures folder 35 | captures/ 36 | 37 | # Google Doc files 38 | *.gsheet 39 | *.gslides 40 | *.gdoc 41 | 42 | # MS Office files 43 | *.xls_ 44 | *.doc_ 45 | *.ppt_ 46 | 47 | # PDF files 48 | *.pdf 49 | 50 | # ZIP files 51 | *.zip 52 | 53 | # VISUAL STUDIO FILES 54 | 55 | # User-specific files 56 | *.suo 57 | *.user 58 | *.userosscache 59 | *.sln.docstates 60 | 61 | # User-specific files (MonoDevelop/Xamarin Studio) 62 | *.userprefs 63 | 64 | # Build results 65 | [Dd]ebug/ 66 | [Dd]ebugPublic/ 67 | [Rr]elease/ 68 | [Rr]eleases/ 69 | x64/ 70 | x86/ 71 | bld/ 72 | [Bb]in/ 73 | [Oo]bj/ 74 | [Ll]og/ 75 | __pycache__/ 76 | 77 | # Visual Studio 2015 cache/options directory 78 | .vs/ 79 | # Uncomment if you have tasks that create the project's static files in wwwroot 80 | #wwwroot/ 81 | 82 | # MSTest test Results 83 | [Tt]est[Rr]esult*/ 84 | [Bb]uild[Ll]og.* 85 | 86 | # NUNIT 87 | *.VisualState.xml 88 | TestResult.xml 89 | 90 | # Build Results of an ATL Project 91 | [Dd]ebugPS/ 92 | [Rr]eleasePS/ 93 | dlldata.c 94 | 95 | # DNX 96 | project.lock.json 97 | artifacts/ 98 | 99 | *_i.c 100 | *_p.c 101 | *_i.h 102 | *.ilk 103 | *.meta 104 | *.obj 105 | *.pch 106 | *.pdb 107 | *.pgc 108 | *.pgd 109 | *.rsp 110 | *.sbr 111 | *.tlb 112 | *.tli 113 | *.tlh 114 | *.tmp 115 | *.tmp_proj 116 | *.log 117 | *.vspscc 118 | *.vssscc 119 | .builds 120 | *.pidb 121 | *.svclog 122 | *.scc 123 | 124 | # Chutzpah Test files 125 | _Chutzpah* 126 | 127 | # Visual C++ cache files 128 | ipch/ 129 | *.aps 130 | *.ncb 131 | *.opendb 132 | *.opensdf 133 | *.sdf 134 | *.cachefile 135 | *.VC.db 136 | *.VC.VC.opendb 137 | 138 | # Visual Studio profiler 139 | *.psess 140 | *.vsp 141 | *.vspx 142 | *.sap 143 | 144 | # TFS 2012 Local Workspace 145 | $tf/ 146 | 147 | # Guidance Automation Toolkit 148 | *.gpState 149 | 150 | # ReSharper is a .NET coding add-in 151 | _ReSharper*/ 152 | *.[Rr]e[Ss]harper 153 | *.DotSettings.user 154 | 155 | # JustCode is a .NET coding add-in 156 | .JustCode 157 | 158 | # TeamCity is a build add-in 159 | _TeamCity* 160 | 161 | # DotCover is a Code Coverage Tool 162 | *.dotCover 163 | 164 | # NCrunch 165 | _NCrunch_* 166 | .*crunch*.local.xml 167 | nCrunchTemp_* 168 | 169 | # MightyMoose 170 | *.mm.* 171 | AutoTest.Net/ 172 | 173 | # Web workbench (sass) 174 | .sass-cache/ 175 | 176 | # Installshield output folder 177 | [Ee]xpress/ 178 | 179 | # DocProject is a documentation generator add-in 180 | DocProject/buildhelp/ 181 | DocProject/Help/*.HxT 182 | DocProject/Help/*.HxC 183 | DocProject/Help/*.hhc 184 | DocProject/Help/*.hhk 185 | DocProject/Help/*.hhp 186 | DocProject/Help/Html2 187 | DocProject/Help/html 188 | 189 | # Click-Once directory 190 | publish/ 191 | 192 | # Publish Web Output 193 | *.[Pp]ublish.xml 194 | *.azurePubxml 195 | # TODO: Comment the next line if you want to checkin your web deploy settings 196 | # but database connection strings (with potential passwords) will be unencrypted 197 | *.pubxml 198 | *.publishproj 199 | 200 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 201 | # checkin your Azure Web App publish settings, but sensitive information contained 202 | # in these scripts will be unencrypted 203 | PublishScripts/ 204 | 205 | # NuGet Packages 206 | *.nupkg 207 | # The packages folder can be ignored because of Package Restore 208 | **/packages/* 209 | # except build/, which is used as an MSBuild target. 210 | !**/packages/build/ 211 | # Uncomment if necessary however generally it will be regenerated when needed 212 | #!**/packages/repositories.config 213 | # NuGet v3's project.json files produces more ignoreable files 214 | *.nuget.props 215 | *.nuget.targets 216 | 217 | # Microsoft Azure Build Output 218 | csx/ 219 | *.build.csdef 220 | 221 | # Microsoft Azure Emulator 222 | ecf/ 223 | rcf/ 224 | 225 | # Windows Store app package directories and files 226 | AppPackages/ 227 | BundleArtifacts/ 228 | Package.StoreAssociation.xml 229 | _pkginfo.txt 230 | 231 | # Visual Studio cache files 232 | # files ending in .cache can be ignored 233 | *.[Cc]ache 234 | # but keep track of directories ending in .cache 235 | !*.[Cc]ache/ 236 | 237 | # Others 238 | ClientBin/ 239 | ~$* 240 | *~ 241 | *.dbmdl 242 | *.dbproj.schemaview 243 | *.pfx 244 | *.publishsettings 245 | node_modules/ 246 | orleans.codegen.cs 247 | 248 | # Since there are multiple workflows, uncomment next line to ignore bower_components 249 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 250 | #bower_components/ 251 | 252 | # RIA/Silverlight projects 253 | Generated_Code/ 254 | 255 | # Backup & report files from converting an old project file 256 | # to a newer Visual Studio version. Backup files are not needed, 257 | # because we have git ;-) 258 | _UpgradeReport_Files/ 259 | Backup*/ 260 | UpgradeLog*.XML 261 | UpgradeLog*.htm 262 | 263 | # SQL Server files 264 | *.mdf 265 | *.ldf 266 | 267 | # Business Intelligence projects 268 | *.rdl.data 269 | *.bim.layout 270 | *.bim_*.settings 271 | 272 | # Microsoft Fakes 273 | FakesAssemblies/ 274 | 275 | # GhostDoc plugin setting file 276 | *.GhostDoc.xml 277 | 278 | # Node.js Tools for Visual Studio 279 | .ntvs_analysis.dat 280 | 281 | # Visual Studio 6 build log 282 | *.plg 283 | 284 | # Visual Studio 6 workspace options file 285 | *.opt 286 | 287 | # Visual Studio LightSwitch build output 288 | **/*.HTMLClient/GeneratedArtifacts 289 | **/*.DesktopClient/GeneratedArtifacts 290 | **/*.DesktopClient/ModelManifest.xml 291 | **/*.Server/GeneratedArtifacts 292 | **/*.Server/ModelManifest.xml 293 | _Pvt_Extensions 294 | 295 | # Paket dependency manager 296 | .paket/paket.exe 297 | paket-files/ 298 | 299 | # FAKE - F# Make 300 | .fake/ 301 | 302 | # JetBrains Rider 303 | .idea/ 304 | *.sln.iml 305 | 306 | # VS Code folder 307 | .vscode/ -------------------------------------------------------------------------------- /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 | --------------------------------------------------------------------------------