<jupyter_start><jupyter_text>This study guide should reinforce and provide practice for all of the concepts you have seen in Unit 3 Sprint 1. There are a mix of written questions and coding exercises, both are equally important to prepare you for the sprint challenge as well as to be able to speak on these topics comfortably in interviews and on the job.If you get stuck or are unsure of something remember the 20 minute rule. If that doesn't help, then research a solution with google and stackoverflow. Only once you have exausted these methods should you turn to your Team Lead - they won't be there on your SC or during an interview. That being said, don't hesitate to ask for help if you truly are stuck.Have fun studying!  Object Oriented Programming  Questions When completing this section, try to limit your answers to 2-3 sentences max and use plain english as much as possible. It's very easy to hide incomplete knowledge and undertanding behind fancy or technical words, so imagine you are explaining these things to a non-technical interviewer.1. What is OOP?```Object Oriented Programming (OOP) is a programming model oriented around objects.  An object is data with unique attributes and behavior.  This is in contrast to functional or procedural programming oriented around functions and logic.```2. What is an object?```An object is data with unique attributes and behavior.```3. What is a class?```A class is a template definition of the methods and variables of a particular object.  A method is similar to a function in functional or proceedural programming.  A class can have sub-classes that inherit characteristics of the class.```4. What is inheritance?```A subclass can inherit characteristics of a class.  In other words, characteristics of a class (parent) can be assigned (inherited) to a subclass (child) allowing it to reuse common logic.```5. What does it mean to "instantiate an object"?```The creation of an instance of an object is called instantiation.  Instantiating an object creates a distinct named identity of the object.```6. What is a dunder method (aka magic method)? What dunder method is called when you instantiate an object?```A dunder method can be identified by the double underscore at the start and end of the method name (e.g. __init__).  The __init__ method is called when you instantiate an object.```7. What is the super method and when is it used?```The super method gives you access to methods in a superclass (parent) from the subclass (child) that inherits from it.```8. What are two other programming paradigms?```Functional programming tries to bind everything to pure mathematical functions.  Javascipt is a popular example. Procedural programming is based on the concept of using procedures, routines, subroutines or functions containing a series of computational steps.  C and Basic are classic examples of procedural progamming languages.```  Practice Problems Create a `person` class with the following attributes and functions`Instance Attributes`- name- age - age should be between 0 and 120, if the age is outside of this range at the time of instantiation, set it to 21- add 2 more instance attributes`Functions`- greets - a function that takes in a name and returns `'Hello, [INPUT NAME]! My name is [INSTANCE NAME], nice to meet you!'`- had_birthday - a function that increments age by 1- Write a function that uses one of the instance attributes you added<jupyter_code># Create the class
class Person:
    # Define the constructor with the instance attributes
    def __init__(self, name, age, height, weight):
        self.name = name
        self.age = age
        if self.age < 1 or self.age > 119:
            self.age = 21
        self.height = height
        self.weight = weight

    # Create the greets method
    def greets(self, new_name):
        print('Hello, ' + new_name + '!' + ' My name is '
              + self.name + ' nice to meet you!')

    # Create the had_birthday method
    def had_birthday(self):
        self.age = self.age + 1
        print("I'm now " + str(self.age) + " years old!")

    # Create the weight_change method
    def weight_change(self, new_weight):
        self.weight = self.weight + new_weight
        print("I now weigh " + str(self.weight) + " pounds!")<jupyter_output><empty_output><jupyter_text>Instantiate your person class, the instance name should be the same as whatever is passed into the name attribute. Make sure you can access all attributes and all functions work as expected.<jupyter_code>joe = Person('Joe', 36, 72, 180)
joe.greets('John')
joe.had_birthday()
joe.weight_change(10)
john = Person('John', -1, 70, 160)
john.age<jupyter_output>Hello, John! My name is Joe nice to meet you!
I'm now 37 years old!
I now weigh 190 pounds!<jupyter_text>Create a `worker` class that inherits from `person`. It should have another dunder method besides `__init__` and have the following attributes and functions`Instance Attributes`- All of the attributes from person- company- job_title- personal_title (mrs, mr, Dr., etc.)- Add 2 more attributes relevant to just the worker class`Functions`- All of the functions from person- Override the greets class to now take in a personal title and name and returns `'Hello, [INPUT PERSONAL TITLE][INPUT NAME]! My name is [INSTANCE NAME], I work for [INSTANCE COMPANY].'`- Add a new function relevant to just the worker class that uses at least 2 attributes<jupyter_code># Create the Worker class inherited from the Person class
class Worker(Person):
    # Define the constructor with the instance attributes
    def __init__(self, name, age, height, weight, company,
                 job_title, personal_title, city, state):
        super().__init__(name, age, height, weight)

        self.company = company
        self.job_title = job_title
        self.personal_title = personal_title
        self.city = city
        self.state = state

    # Create __str__ duncer method
    def __str__(self):
        return f"I work for {self.company}"

    # Overide the Person greets method
    def greets(self, new_title, new_name):
        print('Hello, ' + new_title + ' ' + new_name + '!' + ' My name is '
              + self.name + ' I work for ' + self.company)

    # Create location method
    def location(self):
        print("my location is " + self.city + ", " + self.state)<jupyter_output><empty_output><jupyter_text>Instantiate your worker class, the instance name should be the same as whatever is passed into the name attribute. Make sure you can access all attributes and all functions work as expected.<jupyter_code>betty = Worker('Betty', 38, 60, 120, 'IBM', 'Programmer', 'Ms', 'Austin', 'TX')
print(betty.name)
print(betty.age)
print(betty.height)
print(betty.company)

betty.greets('Ms', 'Smith')
betty.had_birthday()
betty.location()<jupyter_output>Betty
38
60
IBM
Hello, <NAME>! My name is Betty I work for IBM
I'm now 39 years old!
my location is Austin, TX<jupyter_text>Verify all of your code above is PEP8 Compliant  Code Review  Questions When completing this section, try to limit your answers to 2-3 sentences max and use plain english as much as possible. It's very easy to hide incomplete knowledge and undertanding behind fancy or technical words, so imagine you are explaining these things to a non-technical interviewer.1. What is a style guide? Why does it matter?```A style guide provides guidelines for formatting code to improve the readability and consistency of the code.  This helps you and others read, understand and debug the code.```2. What is the style guide for Python called? Name 3 conventions in the style guide.```PEP 8 is the style guide for python code.  Indentation should be 4 spaces, the max line length should usually be 79 chars, and imports should usually be on separate lines.```3. What are we looking for in a code review?```Code reviews can discover issues and help students understand programming concepts.  They should technically push and challenge students.```4. Of the items listed in question 3, which do you find to be the most important one and why?```Challenging students since it required them to explain and defend their code.  They must understand their code in order to explain and defend it.```5. Of the items listed in question 3, make a case for another item to be the most important.```Students having trouble understanding concepts can benefit from both being challenged by a peer and by reviewing a peer.  ```6. What are some non-code considerations when giving a code review?```It's important to not make or take personal critcisms.  The review needs to address the code and technology and the feedback needs to be provided in a tactful manner.```  Practice Problems Use the code below to answer the following questions<jupyter_code>def sumMult35(n):
  #This function finds checks to see if all numbers between 1 and n are a multiple of 3 or five and then adds those ones up. After that it returns that total.
  t = 0
  for i in range(1, n):
    if ((i%3==0)): #mult of 3?
      if (i%5==0): '''multiple of 5?'''
        t=t+i #add up
  return t

sumMult35(16)<jupyter_output><empty_output><jupyter_text>Write a short code review for the code above, that your coworker (the author of the code) will read. Remember two things: they are a fellow human, and also that you are not rewriting it for them, simply giving critique so that they can fix it later.```The primary issue with the code is it does not work as written.  One issue is the formatting which does not follow the PEP8 guidelines.  For example, the indentation does not use 4 spaces and the code may be indented incorrectly.  Also, the comments are difficult to read.  The first comment is too long (over the 79 char convention).  The inline comments have question marks, different formats and don't align.``` Oh, no! You've swapped bodies with your coworker and now have to fix the code. Use your code review to rewrite the function, and make sure it is PEP8 compliant.<jupyter_code># Create a function to total multiples of 3 and 5
def sumMult35(n):
    t = 0
    # Iterate through the 
    for i in range(1, n):
        # Check for multiples of 3 and 5
        if ((i % 3 == 0) or ((i % 5 == 0))):
            t = t + i
    return t


sumMult35(16)<jupyter_output><empty_output><jupyter_text>Containers  Questions 1. What is a container? Why are they used?```A standard unit of software that packages up code and all its dependencies in a stand-alone package that runs reliably from one environment to another.```2. From lecture we know Docker is software to create containers. Name 2 Docker competitors.```Rancher and Kubernetes```  Software Testing  Questions When completing this section, try to limit your answers to 2-3 sentences max and use plain english as much as possible. It's very easy to hide incomplete knowledge and undertanding behind fancy or technical words, so imagine you are explaining these things to a non-technical interviewer.1. What is unit testing and why do we do it?```Unit testing is a level of software testing where individual units of code are tested.  It validates that each unit of software performs as designed.```2. When writing unit tests, what should we consider? Why?```The unit to test.  You want the smallest unit such as an individual function, procedure or method.  A unit that is too large may miss a piece of code.  You also want to test the unit independently of other units or modules of code.  You also need to understand your requirements in order to write effective unit tests.```3. How many unit tests should we have?```One for each individual unit of code.```  Practice Problems For the following problems you'll need to move your person and worker classes to `.py` files.Write the following unit tests in a third `.py` file. Verify they work by running the file, and then copy and paste the code into the cell below.- Verify that an instance of person has an age between 0 and 120 when first instantiated- Verify the same thing with a worker instance- Verify the worker `greet` function uses the `personal_title` of the person passed to it.- Write your own unit test<jupyter_code>pip install -U pytest
!pytest test_pytest2.py
import pytest
from person import Person
from worker import Worker


@pytest.fixture()
def setup():
    worker = Worker("John", 30, 70, 160, "IBM",
                    "Manager", "Mr", "San Francisco", "CA")
    yield worker


def test_age():
    person = Person("Jim", 35, 72, 180)
    assert (person.age > 0 and person.age < 120) is True


def test_worker(setup):
    worker = setup
    assert (worker.age > 0 and worker.age < 120) is True


def test_worker_greets(setup):
    worker = setup
    worker.greets("Mr", "Smith")
    assert worker.personal_title == "Mr"


def test_location(setup):
    worker = setup
    worker.location == "San Francisco, CA"<jupyter_output><empty_output><jupyter_text>The code in all 3 `.py` files should be PEP8 compliant  Git Commands 1. What is the command to make a local copy of one of your repos?```git clone (use SSH key or GitHub repo path)```2. What does the command `git status` do?```Checks the status of the repo against the current state of the working directory.```3. How do you add the changes made in a local repo to your repo on github?```git add .git statusgit commit -m 'comments'git push origin master```4. What is a branch? Why is it used?```A branch is a parallel version of the repo.  You use a branch to isolate development work without affecting other branches of a repo.  The branch does not affect the primary or master branch allowing a developer to work freely without disrupting the live version.```<jupyter_code><jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.06805900394333285, 'fraction_numerical': 0.011537899810135826, 'mean_word_length': 4.022002200220022, 'pattern_counts': {'":': 0, '<': 35, '<?xml version=': 0, '>': 35, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '8', 'dir': 'jupyter-structured-clean-dedup', 'id': '595440', 'license': 'MIT', 'n_tokens_mistral': 3745, 'n_tokens_neox': 3475, 'n_words': 1978, 'path': 'Unit_3_Sprint_1_Study_Guide.ipynb', 'repo_name': 'JimKing100/DS-Unit-3-Sprint-1-Software-Engineering', 'size': '13696'}