All of these tools are valuable in being a good programmer. Also, all of the tool we learned do
not just apply to python. All of these techniques can be implemented in every other coding
language with small changes in syntax.

Hopefully you've enjoyed the various projects so for :)
This is the last one! Good luck!
"""

import numpy as np
from solutions.graphics import *
from solutions.CheckSolutions import CheckSolutions
from solutions.CoronavirusPerson import Person
import matplotlib.pyplot as plt

checkSolutions = CheckSolutions().project5Solutions

NUM_PEOPLE = 100
PERSON_RADIUS = 6

LEFT = 50
RIGHT = 800
TOP = 50
BOTTOM = 600

TIME_SICK = 500
'''
The Simulator Class:
    For this project we will design a simulator.
    The idea is that in our simulator, we will simulate a real world by having people that interact with each other. 
    I wrote a class called Person. The person class has a variety of attributes I will talk about later but know
This is more detailed practice.

Learning Outcomes:
1) Be able to use if else statements
2) use conditional operators such as: > < == <= >= !=

Example 1 is completed as a template.
For each of the following examples, replace blank lines
with the correct equation. If completed correctly, the checkSolutions
will print "Correct Solution" to the terminal.
"""

import numpy as np
from solutions.CheckSolutions import CheckSolutions

checkSolutions = CheckSolutions().conditionalSolutions
randInt = lambda: np.random.randint(-100, 100)


'''
Example 1: 
    use a conditional if else statement to return 
    the largest number between inputs a and b.
'''
def ex1(a, b):
    if a > b:
        return a
    else:
        return b

checkSolutions['example1'](ex1, 5, 6)
Beispiel #3
0
In this tutorial we will cover more complex examples of object
oriented programming. We will also delve into some other OOP
topics including inheritance, interfaces, and polymorphism.

Learning Objectives:
    1. Create classes that reference each other
    2. Create an Abstract/Super class and subclasses
    3. Create your first interface
    4. Bring it all together and learn a little polymorphism


"""

from solutions.CheckSolutions import CheckSolutions
import datetime
checkSolutions = CheckSolutions().classesComplexSolutions
'''
Example 1: Objects in classes in classes in classes ...

In this example we will explore applications of classes. We 
will also see that classes may build upon each other and reference 
one another in their definitions.

Let's write a book!

First, we will outline what this should look like. 

A book is made up of chapters, a table of contents, maybe some end notes. 
Each chapter has a title, a number, and a bunch of pages. Each of these 
pages also has a number, and some text. 
Beispiel #4
0
Learning Objectives:
    1. Read the text file as input to a program
        - Create a text parser
    2. Create a new text file in pyCharm
    3. Write to a text file as output of a program
    4. Redirect standard output std.out

Example 1 is completed as a template.
For each of the following examples, replace blank lines
with the correct functionality. If completed correctly, the checkSolutions
will print "Correct Solution" to the terminal.
"""

import sys
from solutions.CheckSolutions import CheckSolutions
checkSolutions = CheckSolutions().fileIOSolutions

print("----------------------------")

'''
Example 1: 
    Read the file "../fileIO/text1.txt" and print the contents to the terminal.
'''
def ex1():
    file = open("../fileIO/text1.txt", 'r')
    print(file.read())
    file.close()

checkSolutions['example1'](ex1)
print("----------------------------")
Sorting algorithms are fundamental to understanding how to code!
I provide explanations for each of these sorting methods, but more
detailed explanations can be found here: https://www.studytonight.com/data-structures/

Example 1 is completed as a template.
For each of the following examples, replace blank lines
with the correct functionality. If completed correctly, the checkSolutions
will print "Correct Solution" to the terminal.
"""

import numpy as np
import matplotlib.pyplot as plt
import copy
from solutions.CheckSolutions import CheckSolutions

checkSolutions = CheckSolutions().listComplexSolutions
randInt = lambda: np.random.randint(-100, 100)

list_a = [1, 9, 5, 3, 2, 7, 8, 4, 6]
print("list a: " + str(list_a))
print("--------------------------------")
'''
Example 1: Sort with what you know!
    Code a loop that sorts list_a from lowest value to highest value. 
    You are allowed to append lists to a new new_list 
    return the correctly sorted new_list
    
    The idea I'm using in this example is to iterate over list_a and find the lowest value
    every time. Then I remove that value from list_a and add it to new_list. This means we
    need to remove all values from list_a and add them to the new_list. 
        - this is why I have -> while len(list_a) > 0:
Beispiel #6
0
Learning Objectives:
    1. Define a class
    2. Define class attributes
    3. Define a class method
    4. Create a constructor method
    5. Create an object

Example 1 is completed as a template.
For each of the following examples, replace blank lines
with the correct functionality. If completed correctly, the checkSolutions
will print "Correct Solution" to the terminal.
"""

from solutions.CheckSolutions import CheckSolutions
checkSolutions = CheckSolutions().classesSimpleSolutions


'''
Example 1: 
    Define a class called "Example" with one attribute called "attribute1".
'''


class Example:
    def __init__(self):
        self.attribute1 = 1


checkSolutions['example1'](Example())
3) Use basic loop styles in python

Example 1 is completed as a template.
For each of the following examples, replace blank lines
with the correct equation. If completed correctly, the checkSolutions
will print "Correct Solution" to the terminal.

techniques learned:
for loop
while loop
"""

import numpy as np
from solutions.CheckSolutions import CheckSolutions

checkSolutions = CheckSolutions().loopSolutions
randInt = lambda: np.random.randint(-100, 100)
'''
Example 1: 
    Code a for loop that creates the string "0 1 2 3 4 5 "
    Then return the string.
'''


def ex1():
    string = ""
    for i in range(0, 6):
        string += str(i) + " "
    return string

Beispiel #8
0
    1. Draw objects on a canvas
    2. Make objects move on a canvas
    3. Connect user inputs to actions of canvas objects

use this website for help drawing objects: http://anh.cs.luc.edu/handsonPythonTutorial/graphics.html

Example 1 is completed as a template.
For each of the following examples, replace blank lines
with the correct functionality. If completed correctly, the checkSolutions
will print "Correct Solution" to the terminal.
"""

import numpy as np
from solutions.graphics import *
from solutions.CheckSolutions import CheckSolutions
checkSolutions = CheckSolutions().graphicsIntroSolutions
'''
Example 1: 
    In this example we will draw 3 items on a canvas
    1. Draw a circle at point x=250 y=250 with radius 100
        - set the fill of the circle to "lightblue"
    2. Draw a rectangle around the circle so there is no overlap
        - set the fill of the rectangle to "maroon"
    3. Draw a diagonal line at y = -x across both the entire circle and rectangle
        - set the outline of the line to "medium sea green"
        - set the width to 3
    
    return win.items
'''

For each of the following examples, replace blank lines
with the correct functionality. If completed correctly, the checkSolutions
will print "Correct Solution" to the terminal.

After the imports, checkSolutions, and randInt, a bunch of arrays are
predefined. Do not edit these, but understand how the lists are created

Note: before using a list, you must call the list using copy.deepcopy("list")
that way you do not alter the original list
"""

import numpy as np
import copy
from solutions.CheckSolutions import CheckSolutions

checkSolutions = CheckSolutions().listSimpleSolutions
randInt = lambda: np.random.randint(-100, 100)

# how to make various lists:
a = list()
a.append("You")
a.append(" ")
a.append("can")
a.append(" ")
a.append("learn")
a.append(" ")
a.append("python!")

b = [5, 2, 3, 4, 1]
c = b[0:2]
d = b[2:]
Example 1 is completed as a template.
For each of the following examples, replace "None"
with the correct equation. If completed correctly, the checkSolutions
will print "Correct Solution" to the terminal.
All examples are solved with one line.

operations learned:
+ * / ** %
abs() np.exp() np.sqrt()
"""

import numpy as np
from solutions.CheckSolutions import CheckSolutions

checkSolutions = CheckSolutions().functionSolutions
randInt = lambda : np.random.randint(-100, 100)


'''
Example 1: 
    Code the function: a + b = c
    test function using various inputs
'''
def ex1(a, b):
    c = a + b
    return c
checkSolutions['example1'](ex1, 4, 5)

# randInt generates random # between -100 to 100 - good for testing
checkSolutions['example1'](ex1, randInt(), randInt())
between nodes. OOP is a great way to implement different data structures,
including graphs. In this lecture you will be implementing a binary search
tree and learning about its effectiveness. This will give you a TON of practice
applying the OOP techniques you have learned, while also learning some new
sorting and searching algorithms and data structures.

Learning Objectives:
    1. Create a binary search tree using the node class
    2. Develop the BST insert algorithm
    3. Develop the BST search algorithm
    4. Big-O and the Effectiveness of BSTs
    5. What's the point?
"""

from solutions.CheckSolutions import CheckSolutions
checkSolutions = CheckSolutions().searchingSortingSolutions
'''
Example 1: Binary Search Tree

A binary search tree is a type of graph that allows us to reduce the search space by 
half after each node we visit. What does this mean? First look at the example below 
where we put the numbers 1 to 10 in a binary search tree with 5 as the root.

                              __5__
                             /     \
                            2       8     
                           / \     / \ 
                          1   3   6   9
                               \   \   \
                                4   7   10
Beispiel #12
0
Example 1 is completed as a template.
For each of the following examples, replace blank lines
with the correct functionality. If completed correctly, the checkSolutions
will print "Correct Solution" to the terminal.

After the imports, checkSolutions, and randInt, a bunch of arrays are
predefined. Do not edit these, but understand how the lists are created

"""

import numpy as np
import matplotlib.pyplot as plt
from solutions.CheckSolutions import CheckSolutions

checkSolutions = CheckSolutions().dictionarySolutions
randInt = lambda : np.random.randint(-100, 100)


'''
Example 1: 
    Create a dictionary that sorts the data shown below:
    "car", "wings", "6 wheels", "steering wheel", "4 doors"
    "2 wheels", "plane","no doors"
    "4 wheels", "motorcycle", "emergency exits"
'''
def ex1():
    sorted_dictionary = {"car": ["4 wheels", "steering wheel", "4 doors"],
                         "motorcycle": ["2 wheels", "no doors"],
                         "plane": ["6 wheels", "wings", "emergency exits"]}
    return sorted_dictionary
Beispiel #13
0
    * getHeight() - returns height of window
    * getWidth() - returns width of window

Colors we can use: http://www.science.smith.edu/dftwiki/index.php/Tk_Color_Names

Learning Objectives:
    1. Draw objects on a canvas
    2. Make objects move on a canvas
    3. Connect user inputs to actions of canvas objects

use this website for help drawing objects: http://anh.cs.luc.edu/handsonPythonTutorial/graphics.html
"""

from solutions.graphics import *
from solutions.CheckSolutions import CheckSolutions
checkSolutions = CheckSolutions().graphicsComplexSolutions


'''
Example 1 and 2:
    Open each comment block one at a time and solve each problem sequentially
    The check solutions are below, do not edit those...
    Uncomment the check solutions as you go, and after solving the problem, comment it again. 
    
    You may want to copy the commented instructions into a separate text file 
        to read them better while you're coding
'''
'''
Example 1: 
    To start Tetris, lets make a single TetrisBlock class.
    If you forget what a class is look at lecture 13-16.
For each of the following examples, replace blank lines
with the correct functionality. If completed correctly, the checkSolutions
will print "Correct Solution" to the terminal.


It is not possible to check the exact configuration of your graph so compare
your solutions to the correct images by looking at the images in:
    solutions/7_matplotlibIntroductionSolutionsImages
"""


import numpy as np
import matplotlib.pyplot as plt
from solutions.CheckSolutions import CheckSolutions

checkSolutions = CheckSolutions().matplotlibIntro

data_path = "../data/numpy60MeterDashEx.npy"

'''
Example 1: 
    Write a function that loads the data from "data/numpy60MeterDashEx.npy"
     and visualizes it using matplotlib. The intended graph is a scatter plot
     of the data. 
     
     return the x and y coordinates used for plotting (x, y)
'''
def ex1(path):
    '''
    Load data and setup x and y coordinates
    Note: notice that there are no x coordinates with this data
Beispiel #15
0
For each of the following examples, replace blank lines
with the correct functionality. If completed correctly, the checkSolutions
will print "Correct Solution" to the terminal.

After the imports, checkSolutions, and randInt, a bunch of arrays are
predefined. Do not edit these, but understand how the arrays are created

Note: What's nice about numpy rather than lists is that every time we append or delete
something from a numpy array, we create a new numpy array. That way we do not need to
use copy.deepcopy(list) like we did in the list section.
"""

import numpy as np
from solutions.CheckSolutions import CheckSolutions

checkSolutions = CheckSolutions().numpySimpleSolutions
randInt = lambda: np.random.randint(-100, 100)

# how to make various lists:
a = np.array(["You", " ", "can", " ", "learn", " ", "numpy!"])

b = [5, 2, 3, 4, 1]
c = b[0:2]
d = b[2:]

print("list a: " + str(a))
print("list b: " + str(b))
print("list c: " + str(c))
print("list d: " + str(d))

print("------------------------------")