├── Admin
├── Final_Projects.md
├── Syllabus.md
├── cheatsheet.md
├── class_norms.md
├── guide_to_turning_a_program_object_oriented.md
└── resources.md
├── Assignments
├── Homework_3.md
├── final_project.md
├── homework_1.md
├── homework_2.md
└── homework_4
│ ├── homework_4.md
│ ├── homework_4_steps.md
│ └── upacking_tuples.md
├── Monday Febuary 12th
├── Activities
│ ├── grade_calculator.md
│ └── phone_number_actvity.md
├── Lectures
│ ├── demo_for_class
│ │ ├── conditionals.py
│ │ └── sample_program.py
│ ├── review.md
│ └── strings_and_conditionals.md
└── about.md
├── Monday Febuary 26th
├── about.md
├── code
│ ├── 99-2.py
│ ├── 99bottles.py
│ ├── attendees.py
│ ├── days_of_the_week.py
│ ├── intergers.py
│ ├── nested.py
│ ├── password.py
│ ├── range.py
│ ├── sandwich.py
│ └── sleep_in.py
└── lectures
│ ├── lists.md
│ └── loops.md
├── Monday Febuary 5th
├── about.md
├── about_us
│ ├── About_Kelly
│ ├── Alex Salim
│ ├── Alex.md
│ ├── Alex_Ng
│ ├── Andy_Schneider.md
│ ├── Daniel Ran
│ ├── George_Schmitz.md
│ ├── Hamid_Tavakoli
│ ├── Jess_Garson.md
│ ├── Joyce.md
│ ├── Michelle_DAmico.md
│ ├── Washington.md
│ ├── Yasha_Razizadeh
│ ├── ayla.md
│ ├── directions.md
│ ├── example_jess_garson.md
│ ├── jeffw.md
│ ├── michaelshore.md
│ ├── peony.md
│ └── thomas.md
└── how_to_prep_for_this_class.md
├── Monday March 12th
└── about.md
├── Monday March 19th
├── about.md
├── code
│ ├── class_example_1.py
│ ├── class_example_2.py
│ ├── class_example_3.py
│ ├── class_example_4.py
│ └── pbj_part2.py
└── lectures
│ ├── Object_Oriented_Python.md
│ └── making_atom_a_python_editor.md
├── Monday March 26th
├── about.md
└── testing_review
│ ├── __pycache__
│ ├── math.cpython-36.pyc
│ └── my_math.cpython-36.pyc
│ ├── answers.py
│ ├── my_math.py
│ └── test_my_math.py
├── Monday March 5th
├── about.md
├── code
│ ├── class_code.py
│ └── dictionary.py
└── lectures
│ ├── dictionaries.md
│ ├── sets.md
│ └── tuples.md
├── README.md
├── Thursday Febuary 15th
├── Activity
│ └── rewriting_with_functions.md
├── Lectures
│ ├── advanced_conditionals_and_functions.md
│ └── review.md
└── about.md
├── Thursday Febuary 22nd
├── Actvities
│ ├── PBJ_Time.md
│ ├── diagram_a_function.md
│ └── rewrite_your_homework.md
├── about.md
├── code
│ ├── another_option.py
│ ├── global.py
│ ├── keywords.py
│ ├── main.py
│ ├── phone_numbers.py
│ ├── same_name.py
│ └── square.py
└── review_of_functions.md
├── Thursday Febuary 8th
├── about.md
├── group_actvities
│ ├── command_line_activity.md
│ ├── hello_world.md
│ └── how_to_keep_your_fork_current.md
└── live_code.md
├── Thursday March 15th
├── about.md
├── code_and_files
│ ├── .ipynb_checkpoints
│ │ ├── Untitled-checkpoint.ipynb
│ │ ├── file handling-checkpoint.ipynb
│ │ ├── os-checkpoint.ipynb
│ │ ├── pandas-checkpoint.ipynb
│ │ └── pandas_demo-checkpoint.ipynb
│ ├── Untitled.ipynb
│ ├── clean_name_score.csv
│ ├── cleaned_name_score.csv
│ ├── file handling.ipynb
│ ├── file.txt
│ ├── name_score.csv
│ ├── os.ipynb
│ ├── pandas.ipynb
│ ├── pandas_demo.ipynb
│ ├── states.txt
│ ├── turtles.txt
│ └── write_a_message.py
├── lectures
│ ├── file_handling.md
│ ├── how_the_internet_works.md
│ ├── os.md
│ ├── pandas.md
│ └── review.md
└── pair_programming.md
├── Thursday March 1st
├── about.md
├── code
│ ├── break.py
│ ├── continue.py
│ ├── count.py
│ ├── enumerate.py
│ ├── pass.py
│ └── zip.py
└── lectures
│ ├── advanced_loops.md
│ ├── debuggingtalk.pptx
│ └── review_of_python_concepts.md
├── Thursday March 22nd
├── About.md
├── activities
│ ├── finsh_the_tests.md
│ ├── pbj_time.md
│ └── tdd.md
├── code
│ ├── __pycache__
│ │ └── math.cpython-36.pyc
│ ├── inhertiance
│ │ ├── ex_1.py
│ │ ├── ex_2.py
│ │ ├── ex_3.py
│ │ ├── ex_4.py
│ │ └── ex_5.py
│ ├── polymorphism
│ │ ├── ex_1.py
│ │ ├── ex_2.py
│ │ ├── ex_3.py
│ │ └── ex_4.py
│ └── testing
│ │ ├── __pycache__
│ │ └── math.cpython-36.pyc
│ │ ├── my_math.py
│ │ └── test_my_math.py
└── lectures
│ ├── inheritance.md
│ ├── polymorphism.md
│ └── testing.md
└── Thursday March 8th
├── Lectures
├── git_and_github.md
└── virtualenv_pip_and_notebooks.md
├── about.md
└── pair_programming
└── pair_programming.md
/Admin/Final_Projects.md:
--------------------------------------------------------------------------------
1 | Below are the final projects that were submitted for the class. Really excited about these:
2 |
3 | - [Kelly](https://github.com/JakeHammond3/final_game)
4 |
5 | - [Michelle](https://github.com/MichelleDamico/hwpython/blob/master/Trivia_Game.ipynb)
6 |
7 | - [Washington](https://github.com/ferraralopes/NYU-Intro-to-Python-Spring-2018/tree/master/Final%20Project)
8 |
9 | - [Peony](https://github.com/leepeony/py-final-game)
10 |
11 | - [Alex M](https://github.com/AMufel/game)
12 |
13 | - [Alex N](https://github.com/alexng89/FinalProject)
14 |
15 | - [Daniel](https://github.com/danielrein/Text-based-game)
16 |
17 | - [James](https://github.com/jamesravenell/moneydash)
18 |
19 | - [Ayla and Hamid](https://github.com/HamidrezaTavakoli/TheWalk)
20 |
21 | - [Yasha](https://github.com/yvr2/PythonGame)
22 |
23 | - [Celestino](https://github.com/Celestinos23/PythonAssignments/blob/master/gamev1.py)
24 |
25 | - [George](https://github.com/schmgm12/GMS-Intro-Py-Final-Game)
26 |
27 | - [Andy](https://github.com/andyschneider85/Final_Assignment)
28 |
29 | - [Michael](https://github.com/michaelshore93/fighters)
30 |
31 | - [Jeff](https://github.com/jeffnwyatt/final_project )
32 |
33 | - [Joyce](https://github.com/ycy273/joyce_final)
34 |
--------------------------------------------------------------------------------
/Admin/Syllabus.md:
--------------------------------------------------------------------------------
1 | # Syllabus
2 |
3 | We'll be diving into the basics of learning how to code in python. By the time we finish class you will should be able to start writing code in Python on a regular basis.
4 |
5 | ## Monday February 5th
6 | 6:30 PM to 8:00 PM
7 |
8 | This is our first class, and we'll spend the majority of the class setting up for successful semester.
9 |
10 | - Introductions
11 | - Norms for the class
12 | - Class overview
13 | - GitHub set up
14 | - Forking
15 | - Setting up our local environments
16 | - Markdown activity
17 |
18 | ## Thursday February 8
19 | 6:30 PM to 8:00 PM
20 |
21 | We'll get started writing code in python in this class and spend time in the command line getting to know that interface.
22 |
23 | - Markdown review
24 | - Advice on how to learn how to code
25 | - Writing our first program
26 | - Running our first program
27 | - Command line basics
28 | - Command line activity
29 | - Introduce homework assignment 1
30 | - Introduce our project for the class
31 |
32 | ## Monday February 12th
33 | 6:30 - 8:00 PM
34 |
35 | The focus of this class will be getting to know the basics such as operators, strings and conditional statements.
36 |
37 | - Operators
38 | - Data types
39 | - Strings
40 | - Raw input
41 | - Conditionals
42 | - Strings and conditionals activity
43 |
44 | ## Thursday February 15th
45 | 6:30 - 8:00pm
46 |
47 | We'll focus on functions which are the building blocks of programs in python.
48 |
49 | - Homework number 1 show and tell
50 | - Advanced conditionals
51 | - Functions
52 | - Writing programs and passing variables between functions
53 | - Re-writing our homework to include functions
54 | - Introduce homework 2
55 |
56 | ## Thursday February 22nd
57 | 6:30 - 8:00pm
58 |
59 | We're going to make sure we have the basics of functions completely down and have some time to practice writing code with functions.
60 |
61 | - Review of functions
62 | - Scopes
63 | - Practice
64 |
65 | ## Monday February 26th
66 | 6:30 - 8:00pm
67 |
68 | We'll focus on lists and loops for this class. We'll spend some time live coding and end the class by writing a program together as a class.
69 |
70 | - Show and tell homework number 2
71 | - Lists and loops
72 | - Writing a program as a class
73 |
74 | ## Thursday March 1st
75 | 6:30 - 8:00 PM
76 |
77 | This class will focus on teaming up and pair programming on and we'll end class with a lecture on debugging problems.
78 |
79 | - Review
80 | - Pair programming on HackerRank problems
81 | - Presentation of one problem you solved
82 | - Debugging hard problems
83 | - Homework 3 Introduce
84 |
85 | # Monday March 5th
86 | 6:30 - 8:00 PM
87 |
88 | We'll talk about tuples, dictionaries and sets. Review our homework assignments and set up to work together while programming in pairs.
89 |
90 | - Further environment set up
91 | - Data structures in Python
92 | - In class activity
93 |
94 | ## Thursday March 8th
95 | 6:30 - 8:00 PM
96 |
97 | Git basics, virtual environments, install our first library, pip and show off our homework.
98 |
99 | - Git basics
100 | - Virtual environments
101 | - Jupyter notebooks introduction
102 | - Homework 3 show and tell
103 |
104 | ## Monday March 12th
105 | 6:30 - 8:00 PM
106 | Special guest: Reed Spool
107 |
108 | We'll spend this class diving into how the internet works. We'll also review our homework assignments as well.
109 |
110 | - How the internet works
111 | - Homework number 4 introduce
112 |
113 | ## Thursday March 15th
114 | 6:30 - 8:00 PM
115 |
116 | We'll be learning how to traverse files with python.
117 |
118 | - Virtual Environment Review
119 | - File Handling in python
120 | - Pandas
121 | - The OS library
122 | - In class activity
123 |
124 | ## Monday March 19th
125 | 6:30 - 8:00 PM
126 |
127 | This class will focus on the basics of object oriented programming in python.
128 |
129 | - Homework Review
130 | - Object Oriented Python
131 | - Group activity on OOP
132 | - Further environment set up
133 |
134 | ## Thursday March 22nd
135 | 6:30 - 8:00 PM
136 |
137 | We'll get started writing tests in Python
138 |
139 | - Inheritance
140 | - Polymorphism
141 | - We'll learn how to write tests
142 | - Group testing activity
143 | - Choose your own adventure
144 |
145 | ## Monday March 26th
146 | 6:30 - 8:00 PM
147 |
148 | We're going to be working with live data and get started connecting to APIs.
149 |
150 | - Playing our games!
151 | - Learn about APIs
152 | - Connect to APIs
153 | - Saying goodbye
154 |
--------------------------------------------------------------------------------
/Admin/cheatsheet.md:
--------------------------------------------------------------------------------
1 | # Cheatsheet
2 | A one pager on most of the major concepts we've covered.
3 |
4 | ## Command line
5 | pwd - where am I?
6 | cd - change directory
7 | cd .. - go up one directory
8 | ls - list contents
9 | ls - lrt - list contents with more context
10 |
11 | ```bash
12 | pwd
13 | cd Documents
14 | cd ..
15 | ls
16 | ls -lrt
17 | ```
18 |
19 | ## String formatting
20 | String formatting is like mad libs. You can insert in variables into strings.
21 |
22 | ```python
23 | print('Hi {}, you are {} years old and you live in Brooklyn'.format(name, age, city))
24 | ```
25 |
26 | ## Functions
27 | Functions are like a mini program inside of your program that contain inside reusable code. They are only run when they are called and they prevent errors and bugs in our code by avoiding duplication.
28 |
29 | The basic syntax of a function is this:
30 |
31 | ```
32 | def something(arguments):
33 | do something
34 |
35 | # to call the function
36 | something(argument=parameter)
37 | ```
38 |
39 | ```python
40 | def hello(name):
41 | print('Hello {}'.format(name))
42 |
43 | hello(name='Jess')
44 | hello(name='Michelle')
45 | ```
46 |
47 | ## Lists
48 | - Lists are containers that can hold multiple pieces of information.
49 | - Lists are commonly used to hold strings (ex: list of attendees’ names) or numbers (ex: number of attendees for each class).
50 | - Sometimes called arrays.
51 |
52 | ```python
53 | colors = ['red', 'blue', 'green']
54 | ```
55 |
56 | ## Sets
57 | Sets have been defined as a unordered bag of values. Sets have curly brackets around them.
58 |
59 | ```python
60 | colors = {'orange', 'blue', 'teal', 'purple'}
61 | ```
62 |
63 | ## Tuples
64 | Tuples are immutable. Meaning they are an unchangeable, ordered sequence of elements. While they look similar to lists, the difference is you can't change these.
65 |
66 | ```python
67 | days_of_the_week = ('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday')
68 | ```
69 |
70 | ## Dictionaries
71 | Dictionaries have two components: a key and its corresponding value.
72 |
73 | Think of it like a phone book or contact list! If you know my name, (key) you can look up my number (value)
74 |
75 | The basic syntax is as follows:
76 | ```
77 | key: value
78 | ```
79 | ```python
80 | handles = {'Michael': 'michaelshore93', 'Daniel': 'danielrein', 'Andrew': 'andyschneider85'}
81 | ```
82 |
83 | ## Loops
84 | Loops allow us to to automate and repeat tasks in a very short amount of time.
85 |
86 | ### For loop
87 | A for loop lets you use each item one at a time, which is great for performing actions a certain number of times.
88 |
89 | ```
90 | For each item:
91 | do something with that item
92 | ```
93 |
94 | ```python
95 | days_of_the_week = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']
96 |
97 | for day in days_of_the_week:
98 | print(day)
99 | ```
100 |
101 | ### While loop
102 | You can think of the while loop as a repeating conditional statement. After an if statement, the program continues to execute code, but in a while loop, the program jumps back to the start of the while statement until the condition is False.
103 |
104 | ```
105 | while a condition is True:
106 | do something
107 | ```
108 |
109 | ```python
110 | bread = 35
111 | while bread >= 2:
112 | print("I'm making a sandwich")
113 | bread = bread - 2
114 | ```
115 | ## Start a virtualenv
116 | They are a fresh start without the weight of the baggage of your computer so you can install packages in isolation.
117 |
118 | For macs:
119 |
120 | ```
121 | virtualenv newvenv
122 | source newvenv/bin/activate
123 | ```
124 |
125 | For PCs:
126 | ```
127 | virtualenv newenv
128 | . .\newenv\Scripts\activate.ps1
129 | ```
130 | ## Start a jupyter notebook
131 | You will need to make sure you have jupyter installed to your environment.
132 |
133 | ```
134 | pip install jupyter
135 | jupyter notebook
136 | ```
137 |
138 | ## Classes
139 | Classes - a blueprint of an object. Think of this as a blueprint of a house that's about to be built.
140 |
141 | Objects - an instance of a class.
142 |
143 | ```python
144 | class Student:
145 | def __init__(self, name):
146 | self.name = name
147 |
148 | def classroom(self):
149 | print('{} is in class listening to lectures from Jess and pair programming'.format(self.name))
150 |
151 | def frustration(self):
152 | print('{} is getting a lot of syntax errors, cut and pasting all the things from stack overflow'.format(self.name))
153 |
154 | def happiness(self):
155 | print('{} is thinking now - OMG, I solved the error I am so happy and smart'.format(self.name))
156 |
157 |
158 | def main():
159 | yasha = Student('Yasha')
160 | yasha.classroom()
161 | yasha.frustration()
162 | yasha.happiness()
163 | joyce = Student('Joyce')
164 | joyce.classroom()
165 | joyce.frustration()
166 | joyce.happiness()
167 | ```
168 | ## Commit to GitHub
169 | To commit to GitHub use the following steps:
170 |
171 | ```bash
172 | git add .
173 | git commit -m "adding new changes"
174 | git push
175 | ```
176 |
--------------------------------------------------------------------------------
/Admin/class_norms.md:
--------------------------------------------------------------------------------
1 | # Norms
2 | - We are all students, we are all teachers
3 | - Don't be ashamed of asking questions
4 | - No cell phones in class
5 | - Try not to spill your food
6 | - Jess will come to class early and prepared
7 | - Let's learn from each other
8 | - Try to stay focus
9 | - Try to come to class on time
10 | - Email Jess if you can't make it
11 |
--------------------------------------------------------------------------------
/Admin/guide_to_turning_a_program_object_oriented.md:
--------------------------------------------------------------------------------
1 | # Steps to Turning a Hangman Game into a Class Based Version
2 |
3 | The way that I like to think of classes is that's another pattern of thinking of your code so that's a bit more reusable and you repeat yourself a bit. While the perfect use case is something like a game that has many different characters each that have things like health points and things like that.
4 |
5 | This guide will walk you through how to take the code you have and turn it into a classed based version.
6 |
7 | ## Original code
8 | This code was written by Andy.
9 | ```python
10 | guesses = 0
11 | guessed_letters = []
12 | word = "dorito"
13 |
14 |
15 | while guesses < 5:
16 | guess = input("Hi. Please guess a letter.")
17 |
18 | if set(word).intersection(set(guessed_letters)) == set(word):
19 | break
20 |
21 | if guess in word and guess not in guessed_letters:
22 | print("Correct!")
23 | guessed_letters.append(guess)
24 | print("So far you've used ", guessed_letters, "as letters.")
25 | print("You've got",5-guesses,"guesses left.")
26 |
27 | elif guess not in word and guess not in guessed_letters:
28 | guesses += 1
29 | print("Wrong!")
30 | guessed_letters.append(guess)
31 | print("So far you've used ", guessed_letters, "as letters.")
32 | print("You've got",5-guesses,"guesses left.")
33 |
34 | elif guess in guessed_letters:
35 | print("You've already guessed that letter, please guess again.")
36 |
37 | else:
38 | print("ERROR")
39 |
40 | if set(word).intersection(set(guessed_letters)) == set(word):
41 | print("You won!")
42 | else:
43 | print("You lost!")
44 | ```
45 |
46 | ## Step 1 - Define Your Class
47 | Create a class and call it hangman.
48 |
49 | ```python
50 | class Hangman():
51 | ```
52 | ## Step 2: Create the Constructor Method
53 | From here you can define your starting variables
54 |
55 | ```python
56 | def __init__(self, word, guesses=0, guessed_letters=[]):
57 | self.word = word
58 | self.guesses = guesses
59 | self.guessed_letters = guessed_letters
60 | self.word = word
61 | ```
62 |
63 | ## Step 2 - Adding the Guesses Less Than 5 Method
64 | Let's take the code you wrote for what to do if your guesses are less than 5 and turn that into a function.
65 |
66 | ```python
67 | def guesses_less_than_5(self, word, guesses, guessed_letters):
68 | while guesses < 5:
69 | guess = input("Hi. Please guess a letter.")
70 |
71 | if set(word).intersection(set(guessed_letters)) == set(word):
72 | break
73 |
74 | if guess in word and guess not in guessed_letters:
75 | print("Correct!")
76 | guessed_letters.append(guess)
77 | print("So far you've used ", guessed_letters, "as letters.")
78 | print("You've got", 5-guesses, "guesses left.")
79 |
80 | elif guess not in word and guess not in guessed_letters:
81 | guesses += 1
82 | print("Wrong!")
83 | guessed_letters.append(guess)
84 | print("So far you've used ", guessed_letters, "as letters.")
85 | print("You've got", 5-guesses, "guesses left.")
86 |
87 | elif guess in guessed_letters:
88 | print("You've already guessed that letter, please guess again.")
89 |
90 | else:
91 | print("ERROR")
92 | ```
93 | ## Step 3 - Set Intersection
94 | Let's take the code that takes the set intersection and turn that into a method.
95 |
96 | ```python
97 | def set_intersection(self, word, guesses, guessed_letters):
98 | if set(word).intersection(set(guessed_letters)) == set(word):
99 | print("You won!")
100 | else:
101 | print("You lost!")
102 | ```
103 |
104 | ## Tying it together
105 | For this you will use a main function to tie things together. To tie it together.
106 |
107 | ```python
108 | def main():
109 | dorrito = Hangman('dorito')
110 | dorrito.guesses_less_than_5(word=dorrito.word, guesses=dorrito.guesses, guessed_letters=dorrito.guessed_letters)
111 | dorrito.set_intersection(word=dorrito.word, guesses=dorrito.guesses, guessed_letters=dorrito.guessed_letters)
112 |
113 | if __name__ == "__main__":
114 | main()
115 | ```
116 |
117 | ## Full code
118 | ```python
119 | class Hangman():
120 | def __init__(self, word, guesses=0, guessed_letters=[]):
121 | self.word = word
122 | self.guesses = guesses
123 | self.guessed_letters = guessed_letters
124 | self.word = word
125 |
126 | def guesses_less_than_5(self, word, guesses, guessed_letters):
127 | while guesses < 5:
128 | guess = input("Hi. Please guess a letter.")
129 |
130 | if set(word).intersection(set(guessed_letters)) == set(word):
131 | break
132 |
133 | if guess in word and guess not in guessed_letters:
134 | print("Correct!")
135 | guessed_letters.append(guess)
136 | print("So far you've used ", guessed_letters, "as letters.")
137 | print("You've got", 5-guesses, "guesses left.")
138 |
139 | elif guess not in word and guess not in guessed_letters:
140 | guesses += 1
141 | print("Wrong!")
142 | guessed_letters.append(guess)
143 | print("So far you've used ", guessed_letters, "as letters.")
144 | print("You've got", 5-guesses, "guesses left.")
145 |
146 | elif guess in guessed_letters:
147 | print("You've already guessed that letter, please guess again.")
148 |
149 | else:
150 | print("ERROR")
151 |
152 | def set_intersection(self, word, guesses, guessed_letters):
153 | if set(word).intersection(set(guessed_letters)) == set(word):
154 | print("You won!")
155 | else:
156 | print("You lost!")
157 |
158 |
159 | def main():
160 | dorrito = Hangman('dorito')
161 | dorrito.guesses_less_than_5(word=dorrito.word, guesses=dorrito.guesses, guessed_letters=dorrito.guessed_letters)
162 | dorrito.set_intersection(word=dorrito.word, guesses=dorrito.guesses, guessed_letters=dorrito.guessed_letters)
163 |
164 |
165 | if __name__ == "__main__":
166 | main()
167 | ```
168 |
169 | ## So this was a lot of work, why do this?
170 | While this might not be the best example for object oriented programming, if you had a lot of moving pieces or had like 5 or 6 words you wanted to run the same methods on this would be a more robust way to go about doing this and rewrite the same bits of code less.
171 |
--------------------------------------------------------------------------------
/Admin/resources.md:
--------------------------------------------------------------------------------
1 | # Resources
2 | Here are some resources that can help you get started learning how to code.
3 |
4 | - [Code Newbie Podcast](https://www.codenewbie.org/podcast)
5 |
6 | - [Dive into Python3](http://www.diveintopython3.net/)
7 |
8 | - [Learn Python the Hard Way](https://learnpythonthehardway.org/python3/)
9 |
10 | - [Automate the Boring Stuff with Python](https://automatetheboringstuff.com/)
11 |
12 | ## So you want to be a data scientist?
13 |
14 | - [Data Wrangling with Python](https://www.amazon.com/Data-Wrangling-Python-Tools-Easier/dp/1491948817)
15 |
16 | - [Data Analysis in Python](http://www.data-analysis-in-python.org/index.html)
17 |
18 | - [Titanic: Machine Learning from Disaster](https://www.kaggle.com/c/titanic/discussion/5105)
19 |
20 | - [Deep Learning with Python]( https://www.manning.com/books/deep-learning-with-python)
21 |
22 | - [How to do X with Python](https://chrisalbon.com/)
23 |
24 | - [Machine Learning a Probabilistic Prospective](https://www.amazon.com/Machine-Learning-Probabilistic-Perspective-Computation/dp/0262018020)
25 |
26 | ## So you want to write code for the web?
27 |
28 | - [Learn flask, some great resources are listed here](https://www.fullstackpython.com/flask.html)
29 |
30 | - [Django Polls Tutorial](https://docs.djangoproject.com/en/2.0/intro/tutorial01/)
31 |
32 | - [Hello Web App](https://www.amazon.com/Hello-Web-App-Learn-Build-ebook/dp/B00U5MMZ2E/ref=sr_1_1?ie=UTF8&qid=1510599119&sr=8-1&keywords=hello+web+app)
33 |
34 | - [Hello Web App Intermediate](https://www.amazon.com/Hello-Web-App-Intermediate-Concepts/dp/0986365920)
35 |
36 | - [Test-Driven-Development for Web Programming](https://www.obeythetestinggoat.com/pages/book.html#toc)
37 |
38 | - [2 Scoops of Django](https://www.amazon.com/Two-Scoops-Django-1-11-Practices-ebook/dp/B076D5FKFX/ref=sr_1_1?s=books&ie=UTF8&qid=1510598897&sr=1-1&keywords=2+scoops+of+django)
39 |
40 | - [HTML and CSS: Design and Build Websites](https://www.amazon.com/HTML-CSS-Design-Build-Websites/dp/1118008189/ref=sr_1_1?ie=UTF8&qid=1510599157&sr=8-1&keywords=css+and+html)
41 |
42 | - [JavaScript and JQuery](https://www.amazon.com/JavaScript-JQuery-Interactive-Front-End-Development/dp/1118531647)
43 |
44 | ## Not sure yet, that's okay!
45 | Here are some resources for self guided learning. I recommend trying to be very good at Python and the rest should figure itself out in time.
46 |
47 | - [Python 3 Crash Course](https://www.amazon.com/Python-Crash-Course-Hands-Project-Based/dp/1593276036)
48 |
49 | - [Base CS Podcast](https://www.codenewbie.org/basecs)
50 |
51 | - [Writing Idiomatic Python](https://www.amazon.com/Writing-Idiomatic-Python-Jeff-Knupp-ebook/dp/B00B5VXMRG)
52 |
53 | - [Fluent Python](https://www.amazon.com/dp/1491946008?aaxitk=o7.Y1C9z7oJp87fs3ev30Q&pd_rd_i=1491946008&hsa_cr_id=1406361870001)
54 |
55 | - [Pro Python](https://www.amazon.com/Pro-Python-Marty-Alchin/dp/1484203356/ref=sr_1_1?s=books&ie=UTF8&qid=1510598874&sr=1-1&keywords=pro+python)
56 |
57 | - [Refactoring](https://www.amazon.com/Refactoring-Improving-Design-Existing-Code/dp/0201485672/ref=sr_1_1?ie=UTF8&qid=1510598784&sr=8-1&keywords=refactoring+martin+fowler)
58 |
59 | - [Clean Code](https://www.amazon.com/Clean-Code-Handbook-Software-Craftsmanship/dp/0132350882/ref=sr_1_1?s=books&ie=UTF8&qid=1510598926&sr=1-1&keywords=clean+code)
60 |
61 | - [Write music with Python](https://github.com/reckoner165/soundmodular)
62 |
--------------------------------------------------------------------------------
/Assignments/Homework_3.md:
--------------------------------------------------------------------------------
1 | # Homework 3
2 | ## HTML States
3 | Create a program that prints out an HTML drop down menu for all 50 states.
4 |
5 | Here are the steps to complete this assignment.
6 |
7 | ## Step 1: Start with A List
8 | Define your lists of states and list of state abbreviations. You can use [this resource to make it easier](http://www.liststates.com/).
9 |
10 | ## Step 2: Loop it Together
11 | Essentially, you're telling Python:
12 | ```
13 | for each state in my list:
14 | print this state.
15 | ```
16 |
17 | ## Step 3: Add the HTML Around It
18 | Modify your loop to format the html code around the state name. The html for a state drop down is as follows:
19 |
20 | ```html
21 |
24 | ```
25 |
26 | The output of your file should look something like this:
27 |
28 | ```html
29 |
34 | ```
35 |
36 | ## Save it to a File
37 | Once your program runs the way you want it to. We'll cover file handling in a more pythonic way shortly as a class.
38 |
39 | ```bash
40 | python states.py > states.html
41 | ```
42 |
43 | If this isn't working for you can cut and past your output into a file called states.html.
44 |
45 | ***This assignment is due Thursday March 8th***
46 |
--------------------------------------------------------------------------------
/Assignments/final_project.md:
--------------------------------------------------------------------------------
1 | # Final Project!
2 |
3 | ## Text Based Game
4 | Your first assignment is to create a text based game that can be run in your terminal. This game should tell a story of your choosing.
5 |
6 | You should be able to quit the game easily. This should be an original work that is not cut and pasted from the internet. This should incorporate most of what we learned in class. I'm looking for a creative game that doesn't haven't have any syntax errors.
7 |
8 | ***This assignment is due on Monday March 26th at 6:30pm***
9 |
10 | ## How to Submit
11 | - Email Jessica a link to a GitHub repository with your code and directions of how to play your game.
12 |
13 | ## Resources
14 | [Simplest rpg game in python](https://balau82.wordpress.com/2010/06/28/simplest-rpg-game-in-python/)
15 |
16 | [Text based adventure](http://letstalkdata.com/2014/08/how-to-write-a-text-adventure-in-python-part-1-items-and-enemies/)
17 |
18 | [Making a text based adventure game](http://inventwithpython.com/blog/2014/12/11/making-a-text-adventure-game-with-the-cmd-and-textwrap-python-modules/)
19 |
--------------------------------------------------------------------------------
/Assignments/homework_1.md:
--------------------------------------------------------------------------------
1 | # Homework 1
2 | ## Sentence Tweet Length Calculator
3 |
4 | ### Part 1
5 | Create a program that measures how many characters are in a sentence. If the sentence is too long for a tweet make sure the program tells you so, if the sentence fits into a tweet let me know as well.
6 |
7 | ### Part 2
8 | Adjust the code to say how many characters you have remaining to use, or how many you need to trim the sentence by to turn it into a tweet.
9 |
10 | ### Bonus
11 | Twitter recently changed the limit for tweets, refactor your code so that the limit for twitter characters is not hardcoded in if they change the character limit again.
12 |
13 | ***This assignment is due on Thursday February 15th.***
14 |
15 | ### Resources
16 | - [Conditionals in Python 3](https://www.digitalocean.com/community/tutorials/how-to-write-conditional-statements-in-python-3-2)
17 |
18 | - [Len](https://docs.python.org/3/library/functions.html#len)
19 |
20 | - [Input](https://docs.python.org/3/library/functions.html#input)
21 |
--------------------------------------------------------------------------------
/Assignments/homework_2.md:
--------------------------------------------------------------------------------
1 | # Homework 2
2 | ## Part 1: Make HTML Tags
3 |
4 | The web is built with HTML strings like "Yay" which draws Yay as italic text. In this example, the "i" tag makes and which surround the word "Yay". Given tag and word strings, create the HTML string with tags around the word, e.g. "Yay".
5 |
6 | Create a function called make_tags, that will give you a string with tags around it.
7 |
8 | ```
9 | The function you write should give you the following outputs:
10 | make_tags('i', 'Yay') will yield 'Yay'
11 | make_tags('i', 'Hello') will yield 'Hello'
12 | make_tags('cite', 'Yay') will yield 'Yay'
13 | ```
14 |
15 | ## Part 2: Write a Program to Tell If A Number is Odd or Even
16 | Write a program where a user enters a number and the program will tell them if the number is odd or even.
17 |
18 | ## Part 3: Sleep In Calculator
19 | Write a program that let's you know if you can sleep in. If the day is a weekday, let the user know they can't sleep in and have to go to work. If the day is a weekend let them know they can sleep in.
20 |
21 | ***This assignment is due Monday February 26th***
22 |
--------------------------------------------------------------------------------
/Assignments/homework_4/homework_4.md:
--------------------------------------------------------------------------------
1 | # Homework 4
2 | Due Monday March 19th
3 |
4 | ## Goal
5 | The goal of this assignment is to solve problems inside of a jupyter notebook and upload that notebook to a repository on GitHub.
6 |
7 | ## How to submit this assignment
8 | Create a repository called "Name - Homework 4" and please put the code from this assignment there and send me the link.
9 |
10 | ## Due Date
11 | This assignment is due March 19th
12 |
13 | ## Problem 1 - Dictionaries
14 | Inside of a Jupyter notebook create a dictionary with a one sentence definition of all the concepts we covered.
15 |
16 | Use a loop to create an output that looks something like this:
17 |
18 | ```
19 | Dictionary: A collection of key-value pairs.
20 |
21 | String: A series of characters.
22 |
23 | Boolean Expression: An expression that evaluates to True or False.
24 |
25 | Comment: A note in a program that the Python interpreter ignores.
26 |
27 | Value: An item associated with a key in a dictionary.
28 |
29 | Loop: Work through a collection of items, one at a time.
30 |
31 | List: A collection of items in a particular order.
32 |
33 | Key: The first item in a key-value pair in a dictionary.
34 |
35 | Float: A numerical value with a decimal component.
36 | ```
37 |
38 | ## Problem 2 - Sets
39 | Create 2 sets one of your favorite movies and one of another person in your life's favorite movies.
40 |
41 | - What favorite movies do you have in common with the other person?
42 |
43 | - What movies are your favorite but aren't the other persons?
44 |
45 | ## Problem 3 - Tuples
46 | Create a tuple of many of the major tasks you have to complete for the day in the order you have to complete them. So for example the tasks for me are as follows:
47 |
48 | - wake up
49 | - eat breakfast
50 | - go to work
51 | - eat lunch
52 | - leave work
53 | - go the gym
54 | - eat dinner
55 | - read
56 | - sleep
57 |
58 | Create a program that goes through this tuple and tells the story of a typical day for you.
59 |
--------------------------------------------------------------------------------
/Assignments/homework_4/homework_4_steps.md:
--------------------------------------------------------------------------------
1 | # Homework 4 Steps
2 | If you are feeling a bit lost, this document will walk you through how to set up to create a repository, and virtualenv for solving this assignment.
3 |
4 | ## Steps
5 | If you need some guidance in solving this assignment. Here are some steps you can follow.
6 |
7 | ### Step 1 - Make the repository
8 | Make the repository inside of GitHub.
9 |
10 | ### Step 2 - Clone your repository
11 |
12 | This is an example using a repo we created called name_of_repo you will change this to your username and your repository name.
13 | ```
14 | git clone https://github.com/your_github_user_name/name_of_repo.git
15 | cd name_of_repo
16 | ```
17 |
18 | ### Step 3 - Create a virtualenv
19 | You can now create a virtual environment so that you can have fresh environment to upload new packages to.
20 |
21 | For macs:
22 | ```
23 | virtualenv env
24 | source env/bin/activate
25 | ```
26 |
27 | For PCs:
28 | ```
29 | virtualenv env
30 | source env/Scripts/activate
31 | ```
32 |
33 | ### Step 4 - Install jupyter notebook. Install jupyter notebook in your new environment.
34 | Might just be pip instead of pip3 depending on your set up.
35 | ```
36 | pip3 install jupyter
37 | ```
38 |
39 | ### Step 5- Start the notebook
40 | ```
41 | jupyter notebook
42 | ```
43 |
44 | ### Step 6 - Solve the Problems
45 | In the notebook, solve the problems above. Make sure you save the notebook. You might choose to have 3 notebooks for each problem.
46 |
47 | ### Step 7 - End the Notebook
48 | Go back into your terminal end your your notebook session.
49 | ```
50 | control-c
51 | say y when prompted to end the notebook
52 | ```
53 |
54 | ### Step 8 - Add, Commit, and push your code to GitHub.
55 | ```
56 | git add .
57 | git status
58 | git commit -m "adding new notebooks"
59 | git status
60 | git push
61 | ```
62 |
63 | ### Step 9 - Send me a link
64 | Send me a link to your new notebook.
65 |
--------------------------------------------------------------------------------
/Assignments/homework_4/upacking_tuples.md:
--------------------------------------------------------------------------------
1 | # A few solutions on unpacking tuples
2 | Here are a few ways to go about unpacking tuples.
3 |
4 | ## Formatting *
5 | Since tuples are in an order you can use `.format(*task)` to grab each task in an order and bring it into your formatting.
6 |
7 | ```python
8 | tasks = ('Wake up', 'Eat breakfast', 'Coding', 'Go boxing', 'Eat lunch', 'Go to class', 'Eat dinner', 'Watch TV series', 'Sleep')
9 |
10 | def daily(major_tasks):
11 | print("Usually, I'll {} at 10 and {}, and I'll begin {} when having my breakfast. Then I'll leave home at 12 to {}, and after boxing I'll return home to {}. My class start at 3 so I'll leave at 2 to {}, and after the class I {} and {}. Usually, I {} at 2 am.".format(*major_tasks))
12 |
13 |
14 | daily(major_tasks=tasks)
15 | ```
16 |
17 | ## Looping
18 | You can also loop through a python as follows:
19 | ```python
20 | DailyTasks = ('wake up', 'wash up', 'dress up', 'go to work', 'get breakfast', 'chug coffee',
21 | 'work work work', 'eat lunch', 'work work work', 'chug another coffee',
22 | 'work work work', 'leave work (finally!)', '(try to) go to the gym',
23 | 'eat dinner', 'shower', 'watch TV', 'sleep',
24 | 'dream about not finishing my Python homework',
25 | 'realize the Python homework was just a dream', 'sleep soundly')
26 |
27 | print("This is what I do on a daily basis:")
28 | for i in DailyTasks:
29 | print("I {}.".format(i))
30 | ```
31 |
--------------------------------------------------------------------------------
/Monday Febuary 12th/Activities/grade_calculator.md:
--------------------------------------------------------------------------------
1 | ## Grade Calculator
2 |
3 | Write a program that calculates the grade of an assignment the following guidelines:
4 |
5 | 90 - 100: A
6 | 80 - 89: B
7 | 70 - 79: C
8 | 60 - 69: D
9 | Less than 60: F
10 |
11 |
--------------------------------------------------------------------------------
/Monday Febuary 12th/Activities/phone_number_actvity.md:
--------------------------------------------------------------------------------
1 | # Phone Number Activity
2 |
3 | ## Part 1
4 | With a partner in your text editor write a program that tells you what your phone number is formatted like (xxx)xxx-xxxx and what your area code is?
5 |
--------------------------------------------------------------------------------
/Monday Febuary 12th/Lectures/demo_for_class/conditionals.py:
--------------------------------------------------------------------------------
1 | space = 20
2 | if space < 20:
3 | print('We still have space!')
4 | elif space == 20:
5 | print(
6 | 'We are just at capacity, so no room for a friend today srewrkw3rkwl / '
7 | ';rkwesrewrewrw werjwerjwo3pi awrw3ip[ire ;3w4322342.')
8 | else:
9 | print('Sorry, we are full')
10 |
--------------------------------------------------------------------------------
/Monday Febuary 12th/Lectures/demo_for_class/sample_program.py:
--------------------------------------------------------------------------------
1 | question = input("What's your name? ")
2 | print('hi {}'.format(question))
3 |
--------------------------------------------------------------------------------
/Monday Febuary 12th/Lectures/review.md:
--------------------------------------------------------------------------------
1 | # Review
2 |
3 | ## Command Line
4 | We'll type these commands and we'll yell at what they do.
5 | ```bash
6 | pwd
7 | cd Documents
8 | ls
9 | ls -lrt
10 | mkdir review
11 | cd ..
12 | cd Documents/review
13 | touch hello_world.py
14 | atom .
15 | python hello_world.py
16 | cd ~
17 | ```
18 |
19 | ## When does atom . work
20 | Atom . only works when atom is open on your machine. Opening via atom is alright. We'll demo both methods.
21 |
22 | ## How to Sync a Fork
23 | It's okay to be having trouble with git right now. We aren't going to dig deep into this until March 12th (a month from today).
24 |
25 | ```bash
26 | git config --global user.name JessicaGarson
27 | git config --global user.email jessica.garson@gmail.com
28 | git clone https://github.com/JessicaGarson/sample_to_be_forked.git
29 | cd sample_to_be_forked
30 | git remote add upstream https://github.com/jlg17nyu/sample_to_be_forked.git
31 | git fetch upstream
32 | git checkout master
33 | git merge upstream/master
34 | git push
35 | ```
36 |
37 | ## A Note on 2 Factor Authentication
38 | If you are using 2 factor authentication for GitHub (which you should be). If you are using HTTPS Git, instead of entering your password, enter a personal access token. These can be created by going to your
39 | [personal access tokens page](https://github.com/settings/tokens).
40 |
41 | ## How to join the Python IRC Channel
42 | Directions on joining the python IRC channel are [here](https://www.python.org/community/irc/).
43 |
--------------------------------------------------------------------------------
/Monday Febuary 12th/Lectures/strings_and_conditionals.md:
--------------------------------------------------------------------------------
1 | # Expressions, Operators, Strings, Conditionals
2 |
3 | ## The Interactive Shell
4 | The interactive shell, allows you to play around and experiment. Much of testing I do I do from the interactive shell.
5 |
6 | Our text editor Atom, is where we write complete code.
7 |
8 | ## Expressions
9 | Expressions are most basic kind of programming instruction in the language. Expressions consist of values (such as 2) and operators (such as +), and they can always evaluate (that is, reduce) down to a single value.
10 | ```python
11 | 2 + 2
12 | 5 - 3
13 | 3 * 7
14 | 22 / 7
15 | 2 + 3 * 20
16 | ```
17 |
18 | Exponents look like this:
19 | ```python
20 | 2 ** 3
21 | ```
22 |
23 | % is for modulus/remainder:
24 | ```python
25 | 22 % 8
26 | ```
27 |
28 | // is for integer division/floored quotient:
29 | ```python
30 | 22 // 8
31 | ```
32 |
33 | ## Data Types
34 | There are three data types in Python
35 | - Intergers such as 1, 23, -32, 24, 234
36 | - Floating point numbers or floats such as 1.23, 23.23, -4.32, 22.6
37 | - Strings such as 'rwewe', '2si', 'hello', 'anything really'
38 |
39 | ## Variables
40 | Variables are containers for information you can store text, numbers, or any other type of thing!
41 | ```python
42 | name = 'Jess'
43 | print(name)
44 | ```
45 |
46 | ## What's going on with the print function
47 | ```python
48 | print('Hello World!')
49 | ```
50 | The print() function will display the string value inside the parentheses on the screen. We are using the built in function of print which takes in a string as an argument.
51 |
52 | ## What's the difference between these two?
53 | ```python
54 | print(name)
55 | print('name')
56 | ```
57 | One displays the variable name and one displays the word name as a string.
58 |
59 | ## What's a string?
60 | Strings are combinations of characters. They can be letters, numbers, punctuation. They are anything you can make on the keyboard and then some and can include special characters, like tabs and newlines.
61 |
62 | ## You can spot a string by the quotes around them.
63 | ```python
64 | print('Jess')
65 | print("Jess")
66 | ```
67 | It is preferred to use the single quotes but you can use double quotes. You just can't mix the types of quotes.
68 |
69 | ## Triple quotes for long strings
70 | ```python
71 | tale_of_two_cites = '''It was the best of times, it was the worst of times, it was the age of wisdom, it was the age of foolishness, it was the epoch of belief, it was the epoch of incredulity, it was the season of Light, it was the season of Darkness, it was the spring of hope, it was the winter of despair, we had everything before us, we ..'''
72 | ```
73 |
74 | ## New line
75 | There is a special character to use for a new line in a string.
76 | ```python
77 | print('Hi, my name is: \nJessica')
78 | ```
79 |
80 | ## Tabs
81 | There is also a special character to use for tabs
82 | ```python
83 | print('Hi, my name is: \tJessica')
84 | ```
85 |
86 | ## Slicing
87 | Slicing allows us to segment part of the variable we're working with. We're going to play around with slicing an see what happens.
88 | ```python
89 | name[0:]
90 | name[0]
91 | name[1]
92 | name[2]
93 | name[3]
94 | name[4]
95 | name[0:4]
96 | name[0:]
97 | name[0:1]
98 | name[0:3]
99 | name[-4]
100 | name[-3]
101 | name[-2]
102 | name[-1]
103 | name[-4:-1]
104 | ```
105 |
106 | ## String formatting
107 | I like to think of this like mad libs where we are creating sentences that we can insert variables into.
108 |
109 | ```python
110 | hi = 'Hi my name is {}'.format(name)
111 | print(hi)
112 | age = 32
113 | hi_with_age = 'hi my name {} and I am {} years old.'.format(name, age)
114 | print(hi_with_age)
115 | ```
116 |
117 | You can also do math inside of string formatting.
118 |
119 | ```python
120 | tweet = 'My python class is so fun with @JessicaGarson as my instructor'
121 | print(len(tweet))
122 | print('That tweet is {} characters and you have {} remaining characters'.format(len(tweet), 240- len(tweet)))
123 | ```
124 |
125 | ## String Math
126 | Some fun thing happen when you do math with strings.
127 | ```python
128 | print('Jess' + 'Class')
129 | print('Jess' * 3)
130 | ```
131 |
132 | ## Built in Functions for Strings
133 | Functions are take arguments/parameters tell a function or method how to do their action, or what to do it to. A list of built in functions can be found [here](https://docs.python.org/3/library/functions.html).
134 |
135 | ## How long is my string?
136 | ```python
137 | len(tale_of_two_cites)
138 | tale_length = len(tale_of_two_cites)
139 | ```
140 | The built in len function tells you how long a string is. In this example the function/action is len() and the argument/parameter is tale_of_two_cites.
141 |
142 | ## Find
143 | Works like Ctrl-F in most programs but you get back the index(slice) of where the thing you are looking for is located.
144 | ```python
145 | email = 'jlg17@nyu.edu'
146 | print(email.find('@'))
147 | ```
148 |
149 | ## Replace
150 | Works like Find+Replace in most programs.
151 | ```python
152 | twitter = '@JessicaGarson'
153 | print(twitter.replace('@', '#'))
154 | ```
155 |
156 | ## Upper and Lower
157 | Turns a string into upper or lower case letters.
158 |
159 | ```python
160 | print(twitter.upper())
161 | print(twitter.lower())
162 | ```
163 |
164 | ## Count
165 | ```python
166 | upper_tale = tale_of_two_cites.upper()
167 | print(upper_tale.count('IT'))
168 | ```
169 |
170 | ## Input
171 | ```python
172 | question = input("What's your name? ")
173 | print(question)
174 | ```
175 |
176 | ## Conditionals
177 | We use conditionals to compare two things .
178 |
179 | ## Operators for Comparison
180 | ```
181 | == These two things are equal
182 | != NOT! equal to
183 | > Greater than
184 | < Less than
185 | >= Greater than or equal to
186 | <= Less than or equal to
187 | ```
188 |
189 | ```python
190 | 1 == 2
191 | 2 != 3
192 | 5 > 4
193 | 3 < 100
194 | 4 >= 92
195 | 4 <= 5
196 | ```
197 |
198 | ## If Statement
199 | The if statement evaluates whether a statement is true or false, and run code only in the case that the statement is true.
200 |
201 | ```python
202 | space = 15
203 | if space < 20:
204 | print('We still have spaces left')
205 | ```
206 |
207 | ## Else
208 | If none of the conditions meet. Than do this.
209 | ```python
210 | space = 21
211 |
212 | if space < 20:
213 | print('We still have spaces left')
214 | else:
215 | print('Sorry, we are full')
216 | ```
217 |
218 | ## Elif
219 | If there is another condition that is met than do something else.
220 |
221 | ```
222 | if condition:
223 | do something
224 | elif other_condition:
225 | do something else
226 | else:
227 | do another thing
228 | ```
229 |
230 | ```python
231 | space = 19
232 | if space < 20:
233 | print('We still have space left')
234 | elif space == 20:
235 | print('We are just a capacity')
236 | elif space >= 15:
237 | print('We are almost at capacity but we have a few spaces left')
238 | else:
239 | print('Sorry, we are full')
240 | ```
241 |
--------------------------------------------------------------------------------
/Monday Febuary 12th/about.md:
--------------------------------------------------------------------------------
1 | # Monday February 12th
2 | For this class we're going to dive into python and learn about the building blocks of most programs. Slides are found [here](http://jessicagarson.com/NYU-Intro-to-Python-Feb-12).
3 |
4 | ## Agenda
5 | ### 6:30 - 6:45
6 | Review
7 |
8 | ### 6:45 - 7:45
9 | Lecture on Strings and Conditionals
10 | ### 7:45 - 8:00
11 | We'll work through a set of 2 activities.
12 |
13 | ## What We Will Accomplish
14 | We're going dive into the basics of Python. We'll have a better understanding of expressions, operators and strings by the end of the class.
15 |
16 | ## To Prep For Next Class
17 | - Make sure you email me your homework before the start of class.
18 | - [Python Functions](https://www.datacamp.com/community/tutorials/functions-python-tutorial)
19 | - [Your First Python Program](http://www.diveintopython3.net/your-first-python-program.html#declaringfunctions)
20 |
21 | ## Come See Me DJ Tomorrow Night
22 | I'll be coding tomorrow at [Alaphaville in Brooklyn](https://www.facebook.com/events/420515341701539/).
23 |
--------------------------------------------------------------------------------
/Monday Febuary 26th/about.md:
--------------------------------------------------------------------------------
1 | # Monday February 26th
2 | Today we're going to get started with the data structure lists. After we feel good about lists we're going to dive into loops, which allows us to be insanely productive.
3 |
4 | Slides are found [here](http://jessicagarson.com/NYU-Intro-to-Python-Feb-26/).
5 |
6 | ## Agenda
7 | ### 6:30 - 6:45
8 | Homework Review
9 | ### 6:45 - 7:00
10 | Lists
11 | ### 7:00 - 7:30
12 | Loops
13 | ### 7:30 - 8:00
14 | Mob Programming as a Class a Program
15 |
16 | ## Homework Show and Tell
17 | We'll get started with reviewing our homework! Break up into groups of 5 - 6 and go around and discuss how you solved the homework assignment.
18 |
19 | ## How to Prepare for the Next Class
20 | We are going to start out by going over everything we have covered in class thus far and work on problems from HackerRank in pairs. We will end class with a lecture on debugging hard problems.
21 |
--------------------------------------------------------------------------------
/Monday Febuary 26th/code/99-2.py:
--------------------------------------------------------------------------------
1 | for beer in range(99, 0, -1):
2 | if beer >= 1:
3 | print('{} bottles of beer on the wall,{} bottles of beer ...'.format(beer, beer))
4 | print('If one of those bottles should happen to fall, {} bottles of beer on the wall...'.format(beer-1))
5 |
6 | else:
7 | print('{} bottle of beer on the wall,{} bottle of beer ...'.format(beer, beer))
8 | print('If one of those bottles should happen to fall, {} bottles of beer on the wall...'.format('no'))
9 |
--------------------------------------------------------------------------------
/Monday Febuary 26th/code/99bottles.py:
--------------------------------------------------------------------------------
1 | # Using range() and a loop, print out the song like this:
2 |
3 | # 99 bottles of beer on the wall, 99 bottles of beer ...
4 | # If one of those bottles should happen to fall, 98 bottles of beer on the wall
5 | # 98 bottles of beer on the wall, 98 bottles of beer ...
6 | # If one of those bottles should happen to fall, 97 bottles of beer on the wall
7 | for beer in range(99, -1, -1):
8 | print('{} bottles of beer on the wall,{} bottles of beer ...'.format(beer, beer))
9 |
--------------------------------------------------------------------------------
/Monday Febuary 26th/code/attendees.py:
--------------------------------------------------------------------------------
1 | attendees = ['Celestino', 'Yasha', 'Hamid']
2 |
3 | for attendee in attendees:
4 | print('{} is a student in this class'.format(attendee))
5 |
--------------------------------------------------------------------------------
/Monday Febuary 26th/code/days_of_the_week.py:
--------------------------------------------------------------------------------
1 | days_of_the_week = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']
2 |
3 | for day in days_of_the_week:
4 | print(day)
5 |
--------------------------------------------------------------------------------
/Monday Febuary 26th/code/intergers.py:
--------------------------------------------------------------------------------
1 | integers = []
2 |
3 | for i in range(10):
4 | integers.append(i)
5 |
6 | print(integers)
7 |
--------------------------------------------------------------------------------
/Monday Febuary 26th/code/nested.py:
--------------------------------------------------------------------------------
1 | days_of_the_week = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']
2 |
3 | for week in range(0, 5):
4 | print('Week {}'.format(week))
5 |
6 | for day in days_of_the_week:
7 | print(day)
8 |
--------------------------------------------------------------------------------
/Monday Febuary 26th/code/password.py:
--------------------------------------------------------------------------------
1 | password = ''
2 |
3 | while password != 'jessisthebest123!':
4 | print('What is the password?')
5 | password = input()
6 |
--------------------------------------------------------------------------------
/Monday Febuary 26th/code/range.py:
--------------------------------------------------------------------------------
1 | # for number in range(0, 9):
2 | # print(number)
3 |
4 | # for number in range(10):
5 | # print(number)
6 | #
7 | # for number in range(0, 100, 5):
8 | # print(number)
9 | #
10 | for number in range(100, 0, -10):
11 | print(number)
12 |
--------------------------------------------------------------------------------
/Monday Febuary 26th/code/sandwich.py:
--------------------------------------------------------------------------------
1 | bread = 35
2 | while bread >= 2:
3 | print("I'm making a sandwich")
4 | bread = bread - 2
5 |
--------------------------------------------------------------------------------
/Monday Febuary 26th/code/sleep_in.py:
--------------------------------------------------------------------------------
1 | days_of_the_week = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']
2 |
3 |
4 | def sleep_in():
5 | for day in days_of_the_week:
6 | if day == 'Saturday' or day == 'Sunday':
7 | print('Today is {}, I can sleep in today!'.format(day))
8 | else:
9 | print('Today is {}, I have to go to work :('.format(day))
10 |
11 |
12 | def main():
13 | sleep_in()
14 |
15 |
16 | if __name__ == '__main__':
17 | main()
18 |
--------------------------------------------------------------------------------
/Monday Febuary 26th/lectures/lists.md:
--------------------------------------------------------------------------------
1 | # Lists
2 | What are they?
3 | - Lists are containers that can hold multiple pieces of information.
4 | - Lists are commonly used to hold strings (ex: list of attendees’ names) or numbers (ex: number of attendees for each class).
5 | - Sometimes called arrays.
6 |
7 | ## This would be annoying
8 | ```python
9 | attendee1 = 'Celestino'
10 | attendee2 = 'Yasha'
11 | attendee3 = 'Hamid'
12 | ```
13 | ## There's got to be a better way!
14 | There is! Lists are a data structure that allows us to hold multiple values.
15 | - Lists are are created by placing items inside of [ ]
16 | - They are comma separated
17 |
18 | Example from before as a list:
19 | ```python
20 | attendees = ['Celestino', 'Yasha', 'Hamid']
21 | ```
22 |
23 | An empty list looks like this:
24 | ```python
25 | homework_2_not_turned_in = []
26 | ```
27 |
28 | ## How long is my list?
29 | Our friend len works on lists too!
30 | ```python
31 | print(len(attendees))
32 | ```
33 |
34 | ## Slicing does too! Whoa!
35 | ```python
36 | attendees[0]
37 | attendees[1]
38 | attendees[2]
39 | attendees[0:3]
40 | attendees[2]
41 | attendees[3]
42 | ```
43 |
44 | ## Adding one item to a list
45 | .append() allows us to add one item to the end of the list
46 | ```python
47 | attendees.append('Peony')
48 | print(attendees)
49 | ```
50 |
51 | ## Changing list items
52 | We can use slicing to change list items
53 | ```python
54 | attendees[0] = 'Ayla'
55 | print(attendees)
56 | ```
57 |
58 | ## Let's get rid of the last list item
59 | ```python
60 | attendees.pop()
61 | print(attendees)
62 | ```
63 |
64 | ## How do you sort a list?
65 | ```python
66 | votes = [5, 4, 6, 3, 9, 1, 2]
67 | votes.sort()
68 | print(votes)
69 |
70 | attendees.sort()
71 | print(attendees)
72 | ```
73 |
74 | ## What if I don't want the last list item but another place?
75 | We can specify the index(the slicing number) to remove whatever attendee we'd want.
76 | ```python
77 | attendees.pop(1)
78 | print(attendees)
79 | ```
80 | ## What if I want to add more than one item to the end of my list.
81 | .extend() allows us to add a list of extra list elements to our list.
82 | ```python
83 | attendees.extend(['Daniel', 'Joyce', 'Kelly'])
84 | print(attendees)
85 | ```
86 |
87 | ## We can also reverse a list
88 | ```python
89 | print(attendees.reverse())
90 | ```
91 |
92 | ## .split()
93 | You can use .split() to take things from a string and turn it into a list.
94 | ```python
95 | fruits = 'Apples, Oranges, Pears, Bananas'
96 | fruit_list = fruits.split(',')
97 | ```
98 |
99 | ## What about removing more than one item?
100 | Items can be removed from lists by using the del statement. In the same way as it can with .pop(). This will delete the value at the index number you specify within a list but you can also use a range.
101 | ```python
102 | del attendees[0:2]
103 | print(attendees)
104 | ```
105 |
106 | ## Combining 2 lists together
107 | We can use the + operator to add lists together.
108 | ```python
109 | print(votes + attendees)
110 | ```
111 |
--------------------------------------------------------------------------------
/Monday Febuary 26th/lectures/loops.md:
--------------------------------------------------------------------------------
1 | # Loops
2 | Using loops we can automate and repeat tasks in a very short amount of time.
3 |
4 | # For Loop
5 | A for loop lets you use each item one at a time, which is great for performing actions a certain number of times.
6 |
7 | With for loops the repeated execution of code based on a loop counter or loop variable. This means that for loops are used most often when the number of iterations is known before entering the loop.
8 |
9 | ```
10 | For each item:
11 | do something with that item
12 | ```
13 |
14 | # Range
15 | Range creates a list of numbers that we can loop over.
16 |
17 | ```python
18 | for number in range(0,9):
19 | print(number)
20 | ```
21 |
22 | You can pass in between 1 and three arguments into range.
23 |
24 | ## With Range Think Start, Stop, Step
25 | Start states the integer value at which the sequence begins, if this is not included then start begins at 0.
26 |
27 | Stop is always required and is the integer that is counted up to but not included.
28 |
29 | Step sets how much to increase (or decrease in the case of negative numbers) the next iteration, if this is omitted then step defaults to 1.
30 |
31 | ```python
32 | for number in range(10):
33 | print(number)
34 | ```
35 | ```python
36 | for number in range(1, 100, 5):
37 | print(number)
38 | ```
39 | ```python
40 | for number in range(100, 0, -10):
41 | print(number)
42 | ```
43 | ## For Loops + Lists
44 | We can use a for loop to go through a list one by and do something with each item.
45 |
46 | ```python
47 | days_of_the_week = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']
48 |
49 | for day in days_of_the_week:
50 | print(day)
51 | ```
52 |
53 | ```python
54 | attendees = ['Celestino', 'Yasha', 'Hamid']
55 |
56 | for attendee in attendees:
57 | print('{} is a student in this class'.format(attendee))
58 | ```
59 |
60 | ```python
61 | integers = []
62 |
63 | for i in range(10):
64 | integers.append(i)
65 |
66 | print(integers)
67 | ```
68 |
69 | ## There Has To Be a Better Way!
70 | While doing the sleep in problem on the homework, you likely noticed there might be a better way to solve it. Here is a solution with lists and loops!
71 |
72 | ```python
73 | days_of_the_week = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']
74 |
75 |
76 | def sleep_in():
77 | for day in days_of_the_week:
78 | if day == 'Saturday' or day == 'Sunday':
79 | print('Today is {}, I can sleep in today!'.format(day))
80 | else:
81 | print('Today is {}, I have to go to work :('.format(day))
82 |
83 |
84 | def main():
85 | sleep_in()
86 |
87 |
88 | if __name__ == '__main__':
89 | main()
90 | ```
91 | # Nested For Loops
92 | Loops can be nested inside other loops.
93 |
94 | ```
95 | for first iterating variable in outer loop:
96 | do something
97 | for second iterating variable in nested loop:
98 | do something
99 | ```
100 |
101 | ```python
102 | days_of_the_week = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']
103 |
104 | for week in range(1, 5):
105 | print('Week {0}'.format(week))
106 |
107 | for day in days_of_the_week:
108 | print(day)
109 | ```
110 |
111 | ## While Loops
112 | The cousins of conditionals.
113 |
114 | You can think of the while loop as a repeating conditional statement. After an if statement, the program continues to execute code, but in a while loop, the program jumps back to the start of the while statement until the condition is False.
115 |
116 | ```
117 | while a condition is True:
118 | do something
119 | ```
120 |
121 | ```python
122 | bread = 35
123 | while bread >= 2:
124 | print("I'm making a sandwich")
125 | bread = bread - 2
126 | ```
127 |
128 | ```python
129 | password = ''
130 |
131 | while password != 'jessisthebest123!':
132 | print('What is the password?')
133 | password = input()
134 | ```
135 |
--------------------------------------------------------------------------------
/Monday Febuary 5th/about.md:
--------------------------------------------------------------------------------
1 | # Monday February 5th
2 | Our first class together! We'll be getting started learning to code to in Python by making sure we are set up for success together.
3 |
4 | ## Seating
5 | Middle school dance rules apply, Macs sit with Macs and PCs sit with PCs.
6 |
7 | ## Slides
8 | Slides for the class are found [here](http://jessicagarson.com/NYU-Intro-to-Python-Feb-5).
9 |
10 | ## Agenda
11 | ### Welcome
12 | 6:30 - 6:35
13 | ### Introductions
14 | 6:35 - 6:45
15 | ### A Note on Teaching Style and My Story
16 | 6:45 - 6:50
17 | ### Norms for the Class Activity
18 | 6:50 - 7:00
19 | ### Walkthrough the Syllabus
20 | 7:00 - 7:10
21 | ### Setting Up Our GitHub Accounts
22 | 7:10 - 7:15
23 | ### Forking the Repo
24 | 7:15 - 7:20
25 | ### Markdown Activity
26 | 7:20 - 7:30
27 | ### Set Up In Class Time
28 | 7:30 - 7:45
29 | ### Advice for Learning How to Code
30 | 7:45 - 7:55
31 | ### How to Prep for Next Class
32 | 7:55 - 8:00
33 |
34 | ## What We Will Accomplish By the End of Class
35 | - You will have your environment set up to write code in Python3
36 | - You will write code in markdown
37 | - Make your first commit on GitHub
38 | - Make your first pull request
39 | - Help create the norms for our class
40 | - Get to know each other
41 |
42 | ## How to Prep for the Next Class
43 | We'll be focusing on the command line and learning the basics of linux. Below are some recommended resources for you to check out before class Thursday.
44 | - [Command Line Crash Course](https://learnpythonthehardway.org/book/appendixa.html)
45 | - [Linux Tutorial](https://ryanstutorials.net/linuxtutorial/)
46 | - [Linux Video Series](https://www.youtube.com/watch?v=sYwr0HMudRg&list=PLlpCYzlw8-CagGcorCV2DCdnkS9IAU9Ab)
47 | - [Codecademy's Command Line Class](https://www.codecademy.com/learn/learn-the-command-line)
48 |
--------------------------------------------------------------------------------
/Monday Febuary 5th/about_us/About_Kelly:
--------------------------------------------------------------------------------
1 | # Kelly
2 |
3 | ## Motivation for being here
4 | Want to write production level code, want to expand general programming skills for current research job
5 |
6 | ## Area of Interest
7 | Looing to get into data science, data analytics, learn how to scrape, do data visualization, still need to learn about other types of coding
8 |
9 | ## Fun Facts
10 | I'm on a dodgeball team, was involved in a medieval reenactment group for a long time, I love techno
11 |
12 | ## Favorite Movie
13 | Gladiator
14 |
15 | ## Dream Project
16 | Computer Forensics- Solving big international crimes on computers, cybersecurity
17 |
--------------------------------------------------------------------------------
/Monday Febuary 5th/about_us/Alex Salim:
--------------------------------------------------------------------------------
1 | # Alex Salim
2 |
3 | I am an electronic engineer from Venezuela, used to work in an oilfield company called halliburton, came to the us in 2016.
4 |
5 | motivation for being part of the class
6 |
7 | learn a new skill that would provide me with the knowledge to find a job in a tech company.
8 |
9 | ## area of interest
10 |
11 | web development
12 |
13 | ## fun fact
14 |
15 | was stuck with the wifi on my first day of class..
16 |
17 | ## favorite movie
18 |
19 | The pursuit of happiness
20 |
21 | ## dream project
22 |
23 | still deciding.
24 |
25 |
--------------------------------------------------------------------------------
/Monday Febuary 5th/about_us/Alex.md:
--------------------------------------------------------------------------------
1 | # Alex
2 | ## Motivation
3 | I am working in the financial services field at a bank. Since the industry is changing, functions becoming motivated, and I have interest in Python I'd like to be ahead of the game.
4 | ## Area of interest
5 | I am not exactly sure what I would like to write yet.. I'm not creative.. For now I am jus tinterested learning the language itself.
6 | ## Fun facts
7 | I was born in Moscow, Russia and came here 23 years ago! I've also participated in a Spartan Beast obstacle course in 2015. I did injure myself 5 feet before the finish line.. womp womp
8 | ## Favorite movie
9 | I have a few! I like the Saint, The 5th Element and Super Bad!
10 | ##Dream Project
11 | Create a go to platform that brokers, insititutional firms would connect to and exchange fees using crypto currency.
12 |
--------------------------------------------------------------------------------
/Monday Febuary 5th/about_us/Alex_Ng:
--------------------------------------------------------------------------------
1 | # Alex Ng
2 |
3 | Hi y'all, I am originally from Singapore, but spent some time in different parts of the US before ending up in the big apple: New Mexico (HS) and Maine (College).
4 |
5 | ## Motivation for Being Part of the Class
6 | I am looking to master the machine before it renders us redundant!
7 |
8 | ## Area of Interest
9 | Lakers fan.
10 |
11 | ## Fun Facts
12 | Served in the military for 2 years.
13 |
14 | ## Favorite Movie
15 | Harry Potter series. Or literally any other fantasy movies: LOTR, Hobbit etc.
16 |
17 | ## Dream Project
18 | Design an app and become an entrepreneur.
19 |
--------------------------------------------------------------------------------
/Monday Febuary 5th/about_us/Andy_Schneider.md:
--------------------------------------------------------------------------------
1 |
2 | # Andy Schneider
3 | Hi! I'm originally from California, but have been living in New York for going on seven years. I like dogs and rock climbing.
4 |
5 | # Motivation for Being Part of the Class
6 | I have seen the power of programming, especially in Python, and feel like I am a bit belated in joining the party. I've seen how one can basically explore, analyze, and visualize data in a way that feels like writing.
7 |
8 | # Area of Interest
9 | I am mainly interested in data wrangling and modeling. I want to be able to pull data, clean it up, explore it, and set up some models in order to forecast and predict.
10 |
11 | # Fun Facts
12 | I hate bagel bites. Just kidding, who hates bagel bites?
13 |
14 | # Favorite Movie
15 | Wet Hot American Summer
16 |
17 | # Dream Project
18 | Managing the 2020 Democratic presidential candidate's campaign.
19 |
--------------------------------------------------------------------------------
/Monday Febuary 5th/about_us/Daniel Ran:
--------------------------------------------------------------------------------
1 | # Daniel Ran
2 |
3 | I am a musician.
4 |
5 | ## Motivation for Being Part of the Class
6 | Curiosity for programming and need for extra income. I also need to occupy my over-active brain with something.
7 |
8 | ## Area of Interest
9 | Anything requiring problem solving..
10 |
11 | ## Fun Facts
12 | I just finished recording an album using Edgar Allan Poe poems as song lyrics.
13 |
14 | ## Favorite Movie
15 | Taxi Driver, Vertigo, Back To The Future
16 |
17 | ## Dream Project
18 | TBD...
19 |
--------------------------------------------------------------------------------
/Monday Febuary 5th/about_us/George_Schmitz.md:
--------------------------------------------------------------------------------
1 | # George Schmitz
2 |
3 | I am currently a data analyst at a PR/Communications agency here in NYC. I recently graduated from Wake Forest University in North Carolina with a MS in Business Analytics.
4 |
5 | Some of my interests include:
6 | * Demon Deacon Basketball ... Go Deacs!
7 | * Using R for data analysis and visualization
8 | * My two Boston Terriers
9 |
10 | ## Motivation for Being Part of the Class
11 | I'm looking to expand my analytics skills using pandas and am interested in learning about web development.
12 |
13 | ## Area of Interest
14 | I am interested in learning about analytics and machine learning.
15 |
16 | ## Fun Facts
17 | I recently spent time studying abroad in Barcelona, Spain.
18 |
19 | ## Favorite Movie
20 | The Dark Night
21 |
22 | ## Dream Project
23 | Music recognition software like shazam.
24 |
--------------------------------------------------------------------------------
/Monday Febuary 5th/about_us/Hamid_Tavakoli:
--------------------------------------------------------------------------------
1 | I am here to learn Python.
2 | I am interested in using python for machine learning.
3 | Fun fact about it me: I have proved and published my own mathematical equation, which is currently being used in large-complex-structures preliminary designs!
4 | My favorite movie is HarryPotter.
5 | My dream project is yet to be determined!
6 |
--------------------------------------------------------------------------------
/Monday Febuary 5th/about_us/Jess_Garson.md:
--------------------------------------------------------------------------------
1 | # Jess Garson
2 |
3 | I am a developer that just moved from Washington, DC. My interests include making crazy projects with code, planning hackathons, punk rock, and teaching others how to code.
4 |
5 | ## Motivation for Being Part of the Class
6 | I'm always looking to become a better developer and teaching is one of the best ways to do that.
7 |
8 | ## Area of Interest
9 | I like writing code for the web. Django is one of my favorites.
10 |
11 | ## Fun Facts
12 | I have a python tattooed on my arm. I’m also a speed reader.
13 |
14 | ## Favorite Movie
15 | Reality Bites.
16 |
17 | ## Dream Project
18 | Making music with code.
19 |
--------------------------------------------------------------------------------
/Monday Febuary 5th/about_us/Joyce.md:
--------------------------------------------------------------------------------
1 | # Joyce Yu
2 |
3 | I'm a first year master student in NYU, majoring in integrated marketing. Hmm, I'm crazy for coding, I love the sounds when typing on the keyboard.
4 |
5 | ## Motivation for Being Part of the Class
6 | I want to become one of the best marketing analyst. Being familiar with python will actually help finding a job.
7 |
8 | ## Area of Interest
9 | I love writing code for data analytics.
10 |
11 | ## Fun facts
12 | After finished coding, I'll feel like I'm the king of the world.
13 |
14 | ## Favorite Movie
15 | The others. I love horror movies, especially when I'm in great pressure.
16 |
17 | ## Dream Project
18 | Losing weight by coding.
19 |
--------------------------------------------------------------------------------
/Monday Febuary 5th/about_us/Michelle_DAmico.md:
--------------------------------------------------------------------------------
1 | # Michelle D'Amico
2 |
3 | I oversee noncredit and public programming at the NYUSPS Center for Global Affairs.
4 |
5 | ## Motivation for Being Part of the Class
6 | - I am on the hiring committee for our new graduate program in cyber crime and I'd like to have more technical knowledge to help me better evaluate candidates. Also, I've wanted to learn a programming language for a while so this was a perfect time to do this.
7 |
8 | ## Area of Interest
9 | - My dad is a programmer and he's developed some fun skills for his Echo. I'd like to be able to do the same!
10 |
11 | ## Fun Facts
12 | - I was on MTV's Total Request Live my freshman year of college.
13 |
14 | ## Favorite Movie
15 | - Big Lebowski
16 |
17 | ## Dream Project
18 | - Hyperloop
19 |
20 |
--------------------------------------------------------------------------------
/Monday Febuary 5th/about_us/Washington.md:
--------------------------------------------------------------------------------
1 | ## Washington Ferrara-Lopes
2 |
3 | I am 38 years old. I love technology, music, and going to the movies and museams.
4 |
5 | ## Motivation for Being Part of the Class
6 |
7 | I was a Business Analyst in Brazil for 10 years and I interested in learning PYTHON Language. Hopefully, I will be able to find a entry level job when I finish this Diploma Program.
8 |
9 | ## Fun Facts
10 |
11 | I love going to the beach and I always feel depressed in the winter.
12 |
13 | ## Favorite Movie
14 |
15 | Child's Play
16 |
17 | ## Dream Project
18 |
19 | Working in a coding project and creat an app.
20 |
--------------------------------------------------------------------------------
/Monday Febuary 5th/about_us/Yasha_Razizadeh:
--------------------------------------------------------------------------------
1 | # Yasha Razizadeh
2 |
3 | I am a librarian at NYU.
4 |
5 | ## Motivation for Being Part of the Class
6 | I want to be able to more effectively manage metadata at work and stay ahead in my field.
7 |
8 | ## Area of Interest
9 | I think I'll eventually be working mainly with a module called pyMARC which assists in editing large amounts of bibliographic data for library systems. I hope to find some personal areas of interests aside from utilizing code at work.
10 |
11 | ##Fun Facts
12 | I grew up in NYC, my interests/hobbies include 80's heavy metal, guitar, board games, science fiction, and meditation.
13 |
14 | ##Favorite Movie
15 | Finding Forrester, Short Circuit 2... I'm not really a movie person
16 |
17 | ## Dream Project
18 | Being in a world touring band.
19 |
20 |
--------------------------------------------------------------------------------
/Monday Febuary 5th/about_us/ayla.md:
--------------------------------------------------------------------------------
1 | ## Motivation for Being a Part of This Class
2 | - I am looking to learn a new skill
3 | ## Fun Facts About Myself
4 | - I am currently writing a fantasy mixed sci-fi novel.
5 | ## Favorite Movie(s)
6 | - Shawshank Redemption, Titanic, Lord of the Rings Trilogy, Star Wars Trilogy (the originals), Stand By Me, Boss Baby, Giant, Gone with the Wind
7 | ## Dream Project
8 | - Too many to name, but one thing I hope to accomplish within a year is to finish the rough draft of my novel.
9 |
--------------------------------------------------------------------------------
/Monday Febuary 5th/about_us/directions.md:
--------------------------------------------------------------------------------
1 | # Introduce Yourself
2 |
3 | ## Create a Markdown File
4 | Use the following format:
5 |
6 | Make your name the header and write few sentences about you. Have a sub header for the following:
7 |
8 | - Motivation for Being Part of the Class - Why you are here.
9 |
10 | - Area of Interest - What you are looking to do after this class is finished. What type of code you do you like to write.
11 |
12 | - Fun Facts - write some fun facts about yourself.
13 |
14 | - Favorite Movie - what’s your favorite movie?
15 |
16 | - Dream Project – if you can work on anything what would it be.
17 |
18 | ## Submit a Pull Request
19 | When you are finished submit a pull request.
20 |
21 | ## Resources
22 | [Markdown Cheatsheet](https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet)
23 |
24 | [Mastering Markdown](https://guides.github.com/features/mastering-markdown/)
25 |
26 | [Creating a Pull Request](https://help.github.com/articles/creating-a-pull-request/)
27 |
28 | [How to Create a Pull Request on GitHub](https://www.digitalocean.com/community/tutorials/how-to-create-a-pull-request-on-github)
29 |
--------------------------------------------------------------------------------
/Monday Febuary 5th/about_us/example_jess_garson.md:
--------------------------------------------------------------------------------
1 | # Jessica Garson
2 | Hi this is an example one.
3 |
4 |
--------------------------------------------------------------------------------
/Monday Febuary 5th/about_us/jeffw.md:
--------------------------------------------------------------------------------
1 | #Jeff Wyatt
2 |
3 | I'm an educational researcher looking to learn Python so I have new research tools
4 |
5 | ## Motivation for bveing part of the class
6 | I'm looking to learn Python
7 |
8 | ## Area of Interest
9 | Machine learning
10 |
11 | ## Fun facts
12 | I have a 17 lbs dog who wears a muzzle
13 |
14 |
15 | ## Favorite Movie
16 | Silver Linings Playbook
17 |
18 | ## Dream Project
19 | Coding to precict football outcomes
20 |
--------------------------------------------------------------------------------
/Monday Febuary 5th/about_us/michaelshore.md:
--------------------------------------------------------------------------------
1 | Introduction
2 |
3 | Motivation: Genuine interest in Python; Possible job-related uses; Augmentation of a future MBA application.
4 |
5 | Areas of Interest: pandas and other data-related packages.
6 |
7 | Favorite Movie: Star Wars (the particular episode constantly changes)
8 |
9 | Dream Project: A chess engine that could beat AlphaZero.
10 |
11 |
--------------------------------------------------------------------------------
/Monday Febuary 5th/about_us/peony.md:
--------------------------------------------------------------------------------
1 | # Peony
2 |
3 | I'm a data analyst at BarkBox. I used to be in non profit and accounting, then I took a data analytics bootcamp to switch industries.
4 |
5 | ## Motivation for Being Part of the Class
6 |
7 | I'd like more engineering responsibilities at my current position.
8 |
9 | ## Area of Interest
10 |
11 | I'd like to either be a data engineer or a backend developer.
12 |
13 | ## Fun Facts
14 |
15 | I like board games, houseplants, social critique, and being outdoors.
16 |
17 | ## Favorite Movie
18 |
19 | Romeo + Juliet
20 |
21 | ## Dream Project
22 |
23 | I'd like to work on projects that focus on diversity and inclusion in tech.
24 |
--------------------------------------------------------------------------------
/Monday Febuary 5th/about_us/thomas.md:
--------------------------------------------------------------------------------
1 | # Thomas Matzner
2 |
3 | Forecasting within the consumer goods space for the past 7 years at MAC Cosmetics, Lacoste, Pruv vodka and Becca Cosmetics.
4 |
5 | ## Motivation for Being Part of this Class
6 | What can be done with AI & ML fascinates me and I want to learn how to do it myself.
7 |
8 | ## Area of Interest
9 | Consumer Goods
10 |
11 | ## Fun Facts
12 | I like to eat
13 |
14 | ## Favorite Movie
15 | Pineapple Express
16 |
17 | ## My Dream Project
18 | Building an AI to do something cool.
19 |
--------------------------------------------------------------------------------
/Monday Febuary 5th/how_to_prep_for_this_class.md:
--------------------------------------------------------------------------------
1 | # How to Prep for this Class
2 |
3 | ## Make sure you have Python3, Atom and Command Line Interface Installed
4 |
5 | Follow the [directions for set up from Learn Python the Hard Way](https://learnpythonthehardway.org/python3/ex0.html). We will have some time in class to work on our set up as well if anyone is stuck.
6 |
--------------------------------------------------------------------------------
/Monday March 12th/about.md:
--------------------------------------------------------------------------------
1 | # Monday March 12th
2 | Today we're going to hang out with guest lecturer Reed Spool who is going to dive into how the internet works.
3 |
4 | [Slides for today are found here](http://jessicagarson.com/NYU-Intro-to-Python-March-12/#/).
5 |
6 | ## Materials for today
7 | Materials for today are posted on a [different repository](https://github.com/reedspool/lecture_internet_python/). This repo won't be live til later tonight since it has code samples. If you want to follow along here are [notes](https://docs.google.com/document/d/1PtQ1d4J6KV48VQOkB6-_MGU_Q13vWoFjBCd8czttx_Y/edit?usp=sharing).
8 |
9 | ## What if I'm feeling lost?
10 | I'll be at office hours Wednesday, Thursday and Friday. Come and hang out. If these hours don't work for you or you want a google hangout, just send me an email and we will figure something out.
11 |
12 | ### Wednesday
13 | - 6 - 8pm - Swallow Cafe 49 Bogart St, Brooklyn, NY 11206
14 |
15 | ### Thursday
16 | - 9am - 11am - Little Skips 941 Willoughby Ave, Brooklyn, NY 11221
17 | - 4 - 6pm - Think Coffee 248 Mercer St, New York, NY 10012
18 |
19 | ### Friday
20 | - 9 - 12pm - Stonefruit 1058 Bedford Ave, Brooklyn, NY 11205
21 | - 4 - 7pm - Think Coffee 248 Mercer St, New York, NY 10012
22 |
23 | ## Homework 4
24 | Homework 4 is posted and is due Monday.
25 |
26 | ## Resources on git, github, jupyter notebooks, and other recent topics
27 | - [Adding a file to a repository using the command line](https://help.github.com/articles/adding-a-file-to-a-repository-using-the-command-line/)
28 | - [Jupyter Notebook Beginners Guide](https://jupyter-notebook-beginner-guide.readthedocs.io/en/latest/execute.html)
29 | - [How to Start and Run a Jupyter Notebook](https://unidata.github.io/online-python-training/notebook.html)
30 | - [Virtual Environments](https://www.youtube.com/watch?v=N5vscPTWKOk)
31 | - [Understanding Virtual Environments in Python](https://code.tutsplus.com/tutorials/understanding-virtual-environments-in-python--cms-28272)
32 |
33 | ## How to prep for next class
34 | - [10 minute tour of Pandas](https://vimeo.com/59324550)
35 | - [Python 101: How to traverse a directory](https://www.blog.pythonlibrary.org/2016/01/26/python-101-how-to-traverse-a-directory/)
36 | - [File handling python](http://www.techbeamers.com/python-file-handling-tutorial-beginners/)
37 |
--------------------------------------------------------------------------------
/Monday March 19th/about.md:
--------------------------------------------------------------------------------
1 | # Monday March 19th
2 | Today we're going to dive into classes and object oriented python.
3 |
4 | (Slides posted here)[http://jessicagarson.com/NYU-Intro-to-Python-March-19/#/].
5 |
6 | ## Agenda
7 | ### 6:30 - 6:45
8 | Homework review - for this review, let's focus on challenges you faced and how you overcame them.
9 | ### 6:45 - 7:05
10 | Setting up atom
11 | ### 7:05 - 7:45
12 | Classes
13 | ### 7:45 - 8:00
14 | Peanut butter and jelly part 2 as a class
15 |
16 | ## How to prep for next class
17 | Next class we'll be covering inheritance, polymorphism, and testing.
18 | - [Class inheritance](https://www.digitalocean.com/community/tutorials/understanding-class-inheritance-in-python-3)
19 | -[Polymorphism](https://www.digitalocean.com/community/tutorials/how-to-apply-polymorphism-to-classes-in-python-3)
20 | - [Improve Your Python: Understanding Unit Testing](https://jeffknupp.com/blog/2013/12/09/improve-your-python-understanding-unit-testing/)
21 | - [Unittest Introduction](http://pythontesting.net/framework/unittest/unittest-introduction/)
22 | - [Python Unit Testing Tutorial](https://cgoldberg.github.io/python-unittest-tutorial/)
23 | - [Dive into Python TDD Chapter](http://www.diveintopython.net/unit_testing/index.html)
24 | - [Double Loop TDD](http://coding-is-like-cooking.info/2013/04/outside-in-development-with-double-loop-tdd/)
25 | - [Test-Driven Development with Python](http://chimera.labs.oreilly.com/books/1234000000754/index.html)
26 | - [Ned Batchelder: Getting Started Testing - PyCon 2014](https://www.youtube.com/watch?v=FxSsnHeWQBY)
27 | - [Testdriven IO Class](https://testdriven.io/part-one-intro)
28 |
--------------------------------------------------------------------------------
/Monday March 19th/code/class_example_1.py:
--------------------------------------------------------------------------------
1 | class Student:
2 | def classroom(self):
3 | print('in class listening to lectures from Jess and pair programming')
4 |
5 | def frustration(self):
6 | print('getting a lot of syntax errors, cut and pasting all the things from stack overflow')
7 |
8 | def happiness(self):
9 | print('OMG, I solved the error I am so happy and smart')
10 |
--------------------------------------------------------------------------------
/Monday March 19th/code/class_example_2.py:
--------------------------------------------------------------------------------
1 | class Student:
2 | def classroom(self):
3 | print('in class listening to lectures from Jess and pair programming')
4 |
5 | def frustration(self):
6 | print('getting a lot of syntax errors, cut and pasting all the things from stack overflow')
7 |
8 | def happiness(self):
9 | print('OMG, I solved the error I am so happy and smart')
10 |
11 |
12 | def main():
13 | yasha = Student()
14 | yasha.classroom()
15 | yasha.frustration()
16 | yasha.happiness()
17 |
18 |
19 | if __name__ == "__main__":
20 | main()
21 |
--------------------------------------------------------------------------------
/Monday March 19th/code/class_example_3.py:
--------------------------------------------------------------------------------
1 | class Student:
2 | def __init__(self, name):
3 | self.name = name
4 |
5 | def classroom(self):
6 | print('{} is in class listening to lectures from Jess and pair programming'.format(self.name))
7 |
8 | def frustration(self):
9 | print('{} is getting a lot of syntax errors, cut and pasting all the things from stack overflow'.format(self.name))
10 |
11 | def happiness(self):
12 | print('{} is thinking now - OMG, I solved the error I am so happy and smart'.format(self.name))
13 |
14 |
15 | def main():
16 | yasha = Student('Yasha')
17 | yasha.classroom()
18 | yasha.frustration()
19 | yasha.happiness()
20 | joyce = Student('Joyce')
21 | joyce.classroom()
22 | joyce.frustration()
23 | joyce.happiness()
24 |
25 |
26 | if __name__ == "__main__":
27 | main()
28 |
--------------------------------------------------------------------------------
/Monday March 19th/code/class_example_4.py:
--------------------------------------------------------------------------------
1 | class Student:
2 |
3 | # Class variables
4 | insitution = 'NYU'
5 | location = 'NYC'
6 |
7 | # Constructor method with instance variables name and age
8 | def __init__(self, name, age):
9 | self.name = name
10 | self.age = age
11 |
12 | # Method with instance variable followers
13 | def set_followers(self, followers):
14 | print('This student has {} GitHub followers'.format(followers))
15 |
16 |
17 | def main():
18 | # First object, set up instance variables of constructor method
19 | andy = Student('Andy', 28)
20 |
21 | # Print out instance variable name
22 | print(andy.name)
23 | print(andy.age)
24 |
25 | # Print out class variable location
26 | print(andy.location)
27 |
28 | # Second object
29 | george = Student('George', 29)
30 |
31 | # Print out instance variable name
32 | print(george.name)
33 | print(george.age)
34 |
35 | # Use set_followers method and pass followers instance variable
36 | george.set_followers(130)
37 |
38 | # Print out class variable animal_type
39 | print(george.insitution)
40 |
41 |
42 | if __name__ == "__main__":
43 | main()
44 |
--------------------------------------------------------------------------------
/Monday March 19th/code/pbj_part2.py:
--------------------------------------------------------------------------------
1 | # As a class we're going to make some peanut butter jelly sandwiches but with classes
2 |
--------------------------------------------------------------------------------
/Monday March 19th/lectures/Object_Oriented_Python.md:
--------------------------------------------------------------------------------
1 | # Object Oriented Python
2 | So what is object oriented programming? Object oriented programming allows us to have reusable patterns of code. We do this so we can repeat ourselves less.
3 |
4 | If our code is less repetitive, it is more readable and thus easier to maintain.
5 |
6 | This is opposed to procedural programming which is where we have a set of instructions to follow. Older programming languages such as COBAL focus on this type programming. Object oriented programming focuses more on logic than specific instructions.
7 |
8 | ## But wait, I heard about functional programming what's that?
9 | You may have heard of a different paradigm called functional programming and might be wondering what the difference is between that and object oriented programming.
10 | [Here is a great article from CodeNewbie that explains the difference between the two](https://www.codenewbie.org/blogs/object-oriented-programming-vs-functional-programming).
11 |
12 | ## Classes and objects
13 | The two core concepts of object oriented programming are classes and objects.
14 |
15 | Classes - a blueprint of an object. Think of this as a blueprint of a house that's about to be built.
16 |
17 | Objects - an instance of a class.
18 |
19 | ## This looks similar to functions
20 | We have been working with functions for about a month now, we are building off of this concept.
21 |
22 | ## Classes
23 | Everything we put inside a class is something that is common to a group of things.
24 |
25 | ```python
26 | class Student:
27 | def classroom(self):
28 | print('in class listening to lectures from Jess and pair programming')
29 |
30 | def frustration(self):
31 | print('getting a lot of syntax errors, cut and pasting all the things from stack overflow')
32 |
33 | def happiness(self):
34 | print('OMG, I solved the error I am so happy and smart')
35 | ```
36 |
37 | ## Objects
38 | An object is an instance of a class. In this example students in this class are the example.
39 |
40 | Here we are saying Yasha is a student in this class and does the things above we defined has being things that students do.
41 |
42 | ```python
43 | yasha = Student()
44 | ```
45 |
46 | ```python
47 | class Student:
48 | def classroom(self):
49 | print('in class listening to lectures from Jess and pair programming')
50 |
51 | def frustration(self):
52 | print('getting a lot of syntax errors, cut and pasting all the things from stack overflow')
53 |
54 | def happiness(self):
55 | print('OMG, I solved the error I am so happy and smart')
56 |
57 |
58 | def main():
59 | yasha = Student()
60 | yasha.classroom()
61 | yasha.frustration()
62 | yasha.happiness()
63 |
64 |
65 | if __name__ == "__main__":
66 | main()
67 | ```
68 |
69 | ## Something is missing here!
70 | We are missing what's known as a constructor method. The constructor method is used to initialize data. It is run as soon as an object of a class is instantiated. Also known as the `__init__` method.
71 |
72 | We can use a name variable that we can use to assign names to objects.
73 |
74 | ```python
75 | class Student:
76 | def __init__(self, name):
77 | self.name = name
78 |
79 | def classroom(self):
80 | print('{} is in class listening to lectures from Jess and pair programming'.format(self.name))
81 |
82 | def frustration(self):
83 | print('{} is getting a lot of syntax errors, cut and pasting all the things from stack overflow'.format(self.name))
84 |
85 | def happiness(self):
86 | print('{} is thinking now - OMG, I solved the error I am so happy and smart'.format(self.name))
87 |
88 |
89 | def main():
90 | yasha = Student('Yasha')
91 | yasha.classroom()
92 | yasha.frustration()
93 | yasha.happiness()
94 | joyce = Student('Joyce')
95 | joyce.classroom()
96 | joyce.frustration()
97 | joyce.happiness()
98 | ```
99 |
100 | ## Class and instance variables
101 | We can assign variables to the class as well as to the instance.
102 |
103 | ```python
104 | class Student:
105 |
106 | # Class variables
107 | institution = 'NYU'
108 | location = 'NYC'
109 |
110 | # Constructor method with instance variables name and age
111 | def __init__(self, name, age):
112 | self.name = name
113 | self.age = age
114 |
115 | # Method with instance variable followers
116 | def set_followers(self, followers):
117 | print('This student has {} GitHub followers'.format(followers))
118 |
119 |
120 | def main():
121 | # First object, set up instance variables of constructor method
122 | andy = Student('Andy', 28)
123 |
124 | # Print out instance variable name
125 | print(andy.name)
126 |
127 | # Print out class variable location
128 | print(andy.location)
129 |
130 | # Second object
131 | george = Student('George', 29)
132 |
133 | # Print out instance variable name
134 | print(george.name)
135 |
136 | # Use set_followers method and pass followers instance variable
137 | george.set_followers(130)
138 |
139 | # Print out class variable animal_type
140 | print(george.institution)
141 |
142 |
143 | if __name__ == "__main__":
144 | main()
145 | ```
146 |
147 | ## Resources
148 | - [Beginner's Guide - Object Oriented Programming](https://dev.to/charanrajgolla/beginners-guide---object-oriented-programming)
149 | - [Know thy Self - PyCon 2017](https://www.youtube.com/watch?v=byff9LhYXOg)
150 | - [Classes and Inheritance](http://www.jesshamrick.com/2011/05/18/an-introduction-to-classes-and-inheritance-in-python/)
151 | - [How my Dog learned Polymorphism](https://javaranch.com/campfire/StoryPoly.jsp)
152 |
--------------------------------------------------------------------------------
/Monday March 19th/lectures/making_atom_a_python_editor.md:
--------------------------------------------------------------------------------
1 | # Let's Turn Atom Into a Python Editor
2 |
3 | ## Linters
4 | Your new best friend.
5 |
6 | ## Two ways to install a package
7 | ```
8 | apm install package-name
9 | ```
10 | or via the settings menu.
11 |
12 | ## My Packages
13 | Here are the packages I currently have.
14 | ```
15 | ├── atom-beautify@0.32.2
16 | ├── atom-django@0.3.2
17 | ├── atom-file-icons@0.6.0
18 | ├── autocomplete-python@1.10.5
19 | ├── bottom-dock@0.4.4
20 | ├── busy-signal@1.4.3
21 | ├── django-templates@0.5.0
22 | ├── emmet@2.4.3
23 | ├── intentions@1.1.5
24 | ├── language-haskell@1.17.3
25 | ├── linter@2.2.0
26 | ├── linter-flake8@2.3.0
27 | ├── linter-python-pep8@0.2.0
28 | ├── linter-spell@0.15.0 (disabled)
29 | ├── linter-ui-default@1.6.10
30 | ├── markdown-pdf@2.1.0
31 | ├── minimap@4.29.8
32 | ├── project-manager@3.3.5
33 | ├── python-autopep8@0.1.3
34 | ├── script@3.17.3
35 | ├── tidalcycles@0.12.1
36 | └── todo-manager@0.2.10
37 | ```
38 |
39 | ## Take a shortcut
40 | Make sure you keep in mind the keyboard shortcuts for these packages.
41 |
42 | ## Many times you need to pip install things first
43 | For many of these packages you will need to pip install things first.
44 |
45 | ## Resources
46 | -[Setting up a Python Development Environment in Atom](https://hackernoon.com/setting-up-a-python-development-environment-in-atom-466d7f48e297)
47 | -[Recommended GitHub Atom Packages](https://www.pythonmania.net/en/2017/02/27/recommended-atom-packages/)
48 |
--------------------------------------------------------------------------------
/Monday March 26th/about.md:
--------------------------------------------------------------------------------
1 | # Monday March 26th
2 | Our last class together. We'll be getting started by playing each others games, review testing, and learn about APIs. We'll conclude class with some final thoughts.
3 |
4 | Slides can be found [here](http://jessicagarson.com/NYU-Intro-to-Python-March-26/).
5 |
6 | ## Agenda
7 | ### 6:30 - 6:50
8 | Arcade
9 | ### 6:50 - 7:05
10 | Testing review
11 | ### 7:05 - 7:50
12 | APIs workshop
13 | ### 7:50 - 8:00
14 | Parting words
15 |
16 | ## Evaluations Due at Midnight
17 | Make sure you take some to fill this out.
18 |
19 | ## Arcade
20 | We'll get started by playing each others games and viewing code.
21 |
22 | ## Reviewing Testing
23 | We'll quickly go over the testing class from last week as a class
24 |
25 | ## APIs
26 | We'll have a short workshop by Sam Agnew on APIs and what they are.
27 |
28 | Materials from this workshop are found [here](https://github.com/sagnew/APIs-101-workshop/).
29 |
30 | ## Parting Words
31 | We'll take a moment to reflect on our time together and how far we have grown.
32 |
33 | ## Celebration
34 | We'll be celebrating the work we've done together after class
35 |
--------------------------------------------------------------------------------
/Monday March 26th/testing_review/__pycache__/math.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JessicaGarson/NYU-Intro-to-Python-Spring-2018/4c88234b61c2c4d0dfa14daa671a5a8cd9c799c0/Monday March 26th/testing_review/__pycache__/math.cpython-36.pyc
--------------------------------------------------------------------------------
/Monday March 26th/testing_review/__pycache__/my_math.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JessicaGarson/NYU-Intro-to-Python-Spring-2018/4c88234b61c2c4d0dfa14daa671a5a8cd9c799c0/Monday March 26th/testing_review/__pycache__/my_math.cpython-36.pyc
--------------------------------------------------------------------------------
/Monday March 26th/testing_review/answers.py:
--------------------------------------------------------------------------------
1 | import my_math
2 | import unittest
3 |
4 |
5 | class TestMultiply(unittest.TestCase):
6 | """
7 | Test the multiply function from the my_math.py program
8 | """
9 | def test_multiply_int_and_string(self):
10 | result = my_math.multiply('trish', 3)
11 | self.assertEqual(result, 'trishtrishtrish')
12 |
13 |
14 | class TestDivide(unittest.TestCase):
15 | """
16 | Test the divide function from the my_math.py program
17 | """
18 |
19 | def test_divide_strings(self):
20 | self.assertRaises(TypeError, my_math.divide, ('w4jlw', '2432j2'))
21 |
22 |
23 | if __name__ == '__main__':
24 | unittest.main()
25 |
--------------------------------------------------------------------------------
/Monday March 26th/testing_review/my_math.py:
--------------------------------------------------------------------------------
1 | def add(a, b):
2 | return a + b
3 |
4 |
5 | def subtract(a, b):
6 | return a - b
7 |
8 |
9 | def multiply(a, b):
10 | return a * b
11 |
12 |
13 | def divide(a, b):
14 | return float(a) / b
15 |
16 |
17 | def main():
18 | print(add(a=3, b=6))
19 | print(subtract(a=5, b=2))
20 | print(multiply(a=3, b=6))
21 | print(divide(a=5, b=2))
22 |
23 |
24 | if __name__ == "__main__":
25 | main()
26 |
--------------------------------------------------------------------------------
/Monday March 26th/testing_review/test_my_math.py:
--------------------------------------------------------------------------------
1 | import my_math
2 | import unittest
3 |
4 |
5 | class TestAdd(unittest.TestCase):
6 | """
7 | Test the add function from the my_my_math.py program
8 | """
9 |
10 | def test_add_integers(self):
11 | """
12 | Test that the addition of two integers returns the correct total
13 | """
14 | result = my_math.add(1, 2)
15 | self.assertEqual(result, 3)
16 |
17 | def test_add_floats(self):
18 | """
19 | Test that the addition of two floats returns the correct result
20 | """
21 | result = my_math.add(10.5, 2)
22 | self.assertEqual(result, 12.5)
23 |
24 | def test_add_strings(self):
25 | """
26 | Test the addition of two strings returns the two string as one
27 | concatenated string
28 | """
29 | result = my_math.add('abc', 'def')
30 | self.assertEqual(result, 'abcdef')
31 |
32 |
33 | class TestSubtract(unittest.TestCase):
34 | """
35 | Test the subtract function from the my_math.py program
36 | """
37 | def test_subtract_integers(self):
38 | result = my_math.subtract(3, 1)
39 | self.assertEqual(result, 2)
40 |
41 | def test_subtract_floats(self):
42 | result = my_math.subtract(1.0, 0.5)
43 | self.assertEqual(result, 0.5)
44 |
45 | def test_subtract_strings(self):
46 | self.assertRaises(TypeError, my_math.subtract, ('xyz', 'z'))
47 |
48 | # Add a class for testing the multiply function
49 |
50 |
51 | class TestMultiply(unittest.TestCase):
52 | """
53 | Test the multiply function from the my_math.py program
54 | """
55 | def test_multiply_integers(self):
56 | result = my_math.multiply(5, 2)
57 | self.assertEqual(result, 10)
58 |
59 | def test_multiply_floats(self):
60 | result = my_math.multiply(3.0, 1.5)
61 | self.assertEqual(result, 4.5)
62 |
63 | def test_multiply_strings_ints(self):
64 | result = my_math.multiply('trish', 3)
65 | self.assertEqual(result, 'trishtrishtrish')
66 |
67 | def test_multiply_strings(self):
68 | self.assertRaises(TypeError, my_math.multiply, ('yooo', 'hello'))
69 |
70 |
71 | # Add a class for testing divide function
72 | class TestDivide(unittest.TestCase):
73 | """
74 | Test the divide function from the my_math.py program
75 | """
76 | def test_divide_ints(self):
77 | result = my_math.divide(12, 6)
78 | self.assertEqual(result, 2)
79 |
80 | def test_divide_floats(self):
81 | result = my_math.divide(5, 2.5)
82 | self.assertEqual(result, 6)
83 |
84 | def test_divide_string(self):
85 | self.assertRaises(TypeError, my_math.divide, ('yooo', 'hello'))
86 |
87 |
88 | if __name__ == '__main__':
89 | unittest.main()
90 |
--------------------------------------------------------------------------------
/Monday March 5th/about.md:
--------------------------------------------------------------------------------
1 | # Monday March 5th
2 | Today we're going to be digging into data structures in python.
3 |
4 | ## Slides
5 | We do have [slides](http://jessicagarson.com/NYU-Intro-to-Python-March-5/#/)
6 |
7 | ## Note on grading
8 | Still on going. Sorry for any delay here.
9 |
10 | ## Agenda
11 | ### 6:30 - 6:45
12 | Tuples
13 | ### 6:45 - 7:00
14 | Sets
15 | ### 7:00 - 7:45
16 | Dictionaries
17 | ### 7:45 - 8:00
18 | Nested dictionary activity
19 |
20 | ## For the next class
21 | - [Try Git](https://try.github.io/levels/1/challenges/1)
22 | - [How to Set Up a Notebook for Python 3](https://www.digitalocean.com/community/tutorials/how-to-set-up-jupyter-notebook-for-python-3)
23 | - [Virtual Environments](https://realpython.com/blog/python/python-virtual-environments-a-primer/)
24 | - [pip install from Automate the Boring Stuff](https://automatetheboringstuff.com/appendixa/)
25 | - [Intro to Pandas]( https://hackernoon.com/intro-to-pandas-1-an-absolute-beginners-guide-to-machine-learning-and-data-science-a1fed3a6f0f3)
26 |
--------------------------------------------------------------------------------
/Monday March 5th/code/class_code.py:
--------------------------------------------------------------------------------
1 | schools = {
2 | "geometry": {
3 | "coordinates": [
4 | -81.50572799999999,
5 | 39.21675500000001
6 | ],
7 | "type": "Point"
8 | },
9 | "properties": {
10 | "address": "300 Campus Drive, Parkersburg, WV 26104",
11 | "marker-color": "#3F3040",
12 | "marker-symbol": "circle",
13 | "name": "West Virginia University at Parkersburg"
14 | },
15 | "type": "Feature"
16 | }
17 |
18 |
19 | # Question 1: How can we get a dictionary with the key of "coordinates" and a value containing a list of two decimal numbers?
20 |
21 | geometry = schools['geometry']['coordinates']
22 | print(geometry)
23 | print(coordinates)
24 |
25 | # Question 2: How can we get address of the school?
26 | address = schools['properties']['address']
27 | print(address)
28 |
29 | # Question 3: How can we get name of the school?
30 |
31 | print(schools['properties']['name'])
32 |
33 | # Question 4: How can we get the latitude of the school?
34 | latitude = schools ['geometry']['coordinates'][0]
35 | print(latitude)
36 |
37 | # Question 5 (bonus): How can we get the marker-color without the hashtag in front?
38 |
39 | marker = schools ['properties']['marker-color'][1:]
40 | print(marker)
41 |
--------------------------------------------------------------------------------
/Monday March 5th/code/dictionary.py:
--------------------------------------------------------------------------------
1 | handles = {'Michael': 'michaelshore93', 'Sushi', 'Daniel': 'danielrein', 'nothing', 'Andrew': 'andyschneider85', 'Pizza'}
2 | #
3 | print(handles)
4 | #
5 | # print(handles['Daniel'])
6 | #
7 | # print(handles.keys())
8 | #
9 | # for key in handles.keys():
10 | # print('{} is a student in our class'.format(key))
11 | #
12 | # print(handles.values())
13 | #
14 | # for value in handles.values():
15 | # print('GitHub: {}'.format(value))
16 | #
17 | # print(handles.items())
18 | #
19 | # for key, value in handles.items():
20 | # print('{} is the key for the value {}'.format(key, value))
21 | # #
22 | # for name in sorted(handles.keys()):
23 | # print(name)
24 | #
25 | # handles['Alex'] = 'alexng89'
26 | # print(handles)
27 |
28 | # handles.update({'Alex': 'newhandle'})
29 | # print(handles)
30 | #
31 | # del handles['Andrew']
32 | # print(handles)
33 |
34 | # handles.clear()
35 | # print(handles)
36 |
--------------------------------------------------------------------------------
/Monday March 5th/lectures/dictionaries.md:
--------------------------------------------------------------------------------
1 | # Dictionaries
2 |
3 | ## Why
4 | So lets say we wanted to create a list of names and Github handles for each student in the class. If we wanted to look up a specific person's Github handle, how could we do that?
5 |
6 | We could zip together those lists but it would be complicated and messy.
7 |
8 | ## There has got to be better way!
9 | Dictionaries are another way of storing information in Python.
10 |
11 | Dictionaries have two components: a key and its corresponding value.
12 |
13 | Think of it like a phone book or contact list! If you know my name, (key) you can look up my number (value)
14 |
15 | ## Dictionaries like sets are unordered
16 | The order of your dictionary may change as you add or remove items!
17 |
18 | ## What does a dictionary look like
19 | The syntax for a dictionary is:
20 | ```
21 | dictionary = {key: value}
22 | ```
23 | Here is dictionary of GitHub handles:
24 |
25 | ```python
26 | handles = {'Michael': 'michaelshore93', 'Daniel': 'danielrein', 'Andrew': 'andyschneider85'}
27 | ```
28 |
29 | ## Accessing data items with keys
30 | If we want to isolate Daniel’s GitHub username, we can do so by calling the key of Daniel.
31 |
32 | ```python
33 | print(handles['Daniel'])
34 | ```
35 |
36 | # Accessing all the keys
37 | .keys() will create a list of all of the keys in your dictionary.
38 |
39 | ```python
40 | print(handles.keys())
41 | ```
42 | ```python
43 | for key in handles.keys():
44 | print('{} is a student in our class'.format(key))
45 | ```
46 |
47 | ## While dictionaries are unordered, we can sort their keys.
48 |
49 | ```python
50 | for name in sorted(handles.keys()):
51 | print(name)
52 | ```
53 |
54 | # Accessing all the values
55 | .values() will create a list of all of the keys in your dictionary.
56 | ```python
57 | print(handles.values())
58 | ```
59 |
60 | ```python
61 | for value in handles.values():
62 | print('GitHub: {}'.format(value))
63 | ```
64 |
65 | ## Access all the keys and values
66 | If we are interested in all of the items in a dictionary, we can access them with the items() function.
67 | ```python
68 | print(handles.items())
69 | ```
70 | This creates a list of tuples (our new bff from the beginning of class).
71 |
72 | We can loop over these values as well:
73 |
74 | ```python
75 | for key, value in handles.items():
76 | print('{} is the key for the value {}'.format(key, value))
77 | ```
78 |
79 | ## Adding values
80 | You can add values using the following syntax:
81 | ```
82 | dict[key] = value
83 | ```
84 | So if we wanted to add the following
85 | ```python
86 | handles['Alex'] = 'alexng89'
87 | print(handles)
88 | ```
89 |
90 | ## Dict update
91 | We can also add and modify dictionaries by using the dict.update()
92 | ```python
93 | handles.update({'Alex': 'newhandle'})
94 | ```
95 |
96 | ## Removing items
97 | To delete items we can use del to remove items.
98 |
99 | The syntax is follows:
100 | ```
101 | del dict[key]
102 | ```
103 | ```python
104 | del handles['Andrew']
105 | ```
106 | ## Let's say we wanted an empty dictionary
107 | .clear removes your dictionary.
108 |
109 | ```python
110 | handles.clear()
111 | ```
112 |
--------------------------------------------------------------------------------
/Monday March 5th/lectures/sets.md:
--------------------------------------------------------------------------------
1 | # Sets
2 | Sets have been defined as a unordered bag of values. Sets have curly brackets around them.
3 |
4 | ## An empty set looks like this
5 | ```python
6 | people_who_didnt_do_homework_2 = {}
7 | ```
8 |
9 | ## What does a set look like
10 | ```python
11 | colors = {'blue', 'green', 'purple', 'orange', 'yellow'}
12 | print(colors)
13 | ```
14 |
15 | ## So Jess, in one example I saw you defined a set as 'aeiou' but you didn't have the curly brackets around it. What is going on here?
16 | ```python
17 | vowels = set('aeiou')
18 | print(vowels)
19 | ```
20 |
21 | ## Our friend Len again!
22 | ```python
23 | len(vowels)
24 | len(colors)
25 | ```
26 |
27 | ## Slicing
28 | Because of the fact that sets are unordered slicing won't work here.
29 |
30 | ## Adding one value to a set
31 | .add() allows you to add one value to the set.
32 | ```python
33 | colors.add('teal')
34 | print(colors)
35 | colors.add('purple')
36 | print(colors)
37 | ```
38 |
39 | ## Whoa! Why didn't purple appear here when we printed it?
40 | Because we can only have one value that is the same.
41 |
42 | ## Adding more values to a set
43 | .update() allows us to add more values to a set.
44 | ```python
45 | a_set = {1, 2, 3}
46 | a_set.update({2, 4, 6})
47 |
48 | colors.update({'pink', 'white', 'black', 'silver'})
49 | print(colors)
50 | ```
51 |
52 | ## Removing items from a set
53 | .discard() removes one item at a time.
54 | ```python
55 | a_set.discard(1)
56 | print(a_set)
57 | colors.discard('black')
58 | print(colors)
59 | ```
60 | .pop() will remove a random item from the list
61 | ```python
62 | a_set.pop()
63 | colors.pop()
64 | ```
65 |
66 | ## True/False sets
67 | ```python
68 | 'black' in colors
69 | 'green' in colors
70 | ```
71 | ## Adding sets together
72 | You can't use the plus operator on sets like we did with tuples.
73 |
74 | ## Common set methods
75 | - The union() method returns a new set containing all the elements that are in either set.
76 | ```python
77 | a_set = {5, 6, 9 , 10, 14}
78 | b_set = {9, 4, 3, 10, 19, 14}
79 | a_set.union(b_set)
80 | ```
81 | - The intersection() method returns a new set containing all the elements that are in both sets.
82 | ```python
83 | a_set.intersection(b_set)
84 | ```
85 | - The difference() method returns a new set containing all the elements that are in a_set but not b_set.
86 | ```python
87 | a_set.difference(b_set)
88 | ```
89 | - The symmetric_difference() method returns a new set containing all the elements that are in exactly one of the sets.
90 | ```python
91 | a_set.symmetric_difference(b_set)
92 | ```
93 |
--------------------------------------------------------------------------------
/Monday March 5th/lectures/tuples.md:
--------------------------------------------------------------------------------
1 | # Tuples
2 | Tuples are immutable. Meaning they are an unchangeable, ordered sequence of elements. While they look similar to lists, the difference is you can't change these.
3 |
4 | ## So when would I use tuples?
5 | We use tuples when you don't want things to be changed. Because these can't be changed in the same was list they are considered faster from an optimization perspective.
6 |
7 | ## We know tuples by the ()
8 | Here is an example tuple:
9 |
10 | ```python
11 | days_of_the_week = ('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday')
12 | ```
13 |
14 | ## Why is the above example good?
15 | Because the order of days is unchanging.
16 |
17 | ## An empty tuple looks like this
18 | ```python
19 | no_show_for_class_today = ()
20 | ```
21 |
22 | ## Our good friend Len!
23 | Also works for tuples.
24 |
25 | ```python
26 | len(days_of_the_week)
27 | ```
28 |
29 | ## Slice it up
30 | Slicing also works here too!
31 |
32 | ```python
33 | days_of_the_week[0]
34 | days_of_the_week[1]
35 | days_of_the_week[2]
36 | days_of_the_week[3]
37 | days_of_the_week[4]
38 | days_of_the_week[5]
39 | days_of_the_week[6]
40 | days_of_the_week[0:3]
41 | days_of_the_week[:5]
42 | days_of_the_week[2:6]
43 | days_of_the_week[:2]
44 | days_of_the_week[-3:-1]
45 | ```
46 |
47 | ## What happens if we multiply tuples
48 | Remember when multiplied a variable that contained a string and it printed 3 times.
49 | ```python
50 | print(days_of_the_week * 3)
51 | ```
52 |
53 | ## Min and Max
54 | If you are using numeric tuples min allows you to grab the lowest value and max allows you to grab the highest.
55 | ```python
56 | votes = (5, 23, 99, 6, 9, 10)
57 | print(max(votes))
58 | print(min(votes))
59 | ```
60 |
61 | ## Can you add tuples together in the way we did with lists to combine them together?
62 | Yes you can.
63 |
64 | ```python
65 | days_of_the_week + votes
66 | ```
67 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # NYU-Intro-to-Python-Spring-2018
2 | Spring Intro to Python Class at NYU
3 |
--------------------------------------------------------------------------------
/Thursday Febuary 15th/Activity/rewriting_with_functions.md:
--------------------------------------------------------------------------------
1 | # Rewriting with Functions
2 | Work in groups of 3
3 |
4 | ## Start With the Homework
5 | Let's rewrite so that all the code runs with functions and a main function.
6 |
7 | ## If You Finish Early
8 | Rewrite the phone number program from Monday using functions.
9 |
10 | ## Need More Problems
11 | Get started on your next homework assignment.
12 |
--------------------------------------------------------------------------------
/Thursday Febuary 15th/Lectures/advanced_conditionals_and_functions.md:
--------------------------------------------------------------------------------
1 | # Advanced Conditionals and Functions
2 |
3 | # Advanced Conditionals
4 | We're going to dive into some advanced uses of conditionals
5 |
6 | ## In
7 | The in keyword, when used with a conditional, tells you whether some text appears in a string.
8 |
9 | ```python
10 | if 'Messica Arson' in article:
11 | print('It is so awesome Jess got her DJ project in this article')
12 | ```
13 |
14 | ## And
15 | Using the and keyword, both conditions must be true for the print statement to run.
16 |
17 | ```python
18 | if homework_turned_in == 0 and homework_assigned == 1:
19 | print('Jess is sad')
20 | ```
21 |
22 | ## Or
23 | Using the or keyword, either condition could be true for the print statement to run.
24 | ```python
25 | if state == 'MD' or state == 'DC' or state == 'DE' or state == 'VA' or state == 'PA':
26 | print('You are from the Mid-Atlantic region')
27 | ```
28 |
29 | ## Nested Conditionals
30 | ```python
31 | if state == 'NY':
32 | print('You are in NY')
33 | elif state == 'NJ':
34 | print('You are in NJ')
35 | elif state == ('CT')
36 | print('')
37 | else:
38 | print('We only service the New York Region')
39 |
40 | if state == 'PA':
41 | print('You are welcome to visit us still')
42 | elif state == 'CA':
43 | print('Wow, that would be quite the drive')
44 | ```
45 |
46 | ## Comments
47 | Comments are code that doesn't run.
48 |
49 | ```python
50 | # I am a comment, I don't run
51 | print('hello world!')
52 | ```
53 |
54 | ## General Advice
55 | If you are repeating yourself, you are likely doing it wrong.
56 |
57 | ## Functions
58 | We've already been working with them but we can create our own!
59 |
60 | ```python
61 | tweet = 'My Professor @JessicaGarson is so awesome'
62 | len(tweet)
63 | tweet_length = len(tweet)
64 | print(tweet)
65 | input("What's your favorite video game? ")
66 | ```
67 |
68 | ## So What Are Functions
69 | They are like a mini program inside of your program that contain inside reusable code. They are only run when they are called and they prevent errors and bugs in our code by avoiding duplication.
70 |
71 | ## Let's Write a Function
72 | We can create a function for our hello world program:
73 | ```python
74 | def hello_world():
75 | print('Hello World!')
76 |
77 | hello_world()
78 | ```
79 |
80 | All functions have what's know as a def statement that allows us to define our function. And inside of the body of our code we can write our code in it.
81 |
82 | ```python
83 | def hello(name):
84 | print('Hello {}'.format(name))
85 |
86 | hello('Jess')
87 | hello('Michelle')
88 |
89 | hello(name='Jess')
90 | hello(name='Michelle')
91 | ```
92 |
93 | ```python
94 | def profile_info(username, followers):
95 | print('Username: {}'.format(username))
96 | print('Followers: {}'.format(followers))
97 |
98 | # Call function with parameters assigned as above
99 | profile_info('sammyshark', 945)
100 |
101 | # Call function with keyword arguments
102 | profile_info(username='sammyshark', followers=945)
103 | profile_info(followers=945, username='sammyshark')
104 | ```
105 |
106 | ## Arguments/Parameters
107 | Functions take in parameters/arguments. Parameters are the variables inside the function. Arguments are the value passed into the function.
108 |
109 | ```python
110 | def add_numbers(x, y, z):
111 | a = x + y
112 | b = x + z
113 | c = y + z
114 | print(a, b, c)
115 |
116 | add_numbers(1, 2, 3)
117 | ```
118 |
119 | ## Return Value
120 | The return value is allows us to specify if your function should output a value.
121 |
122 | You should end your function with a return statement if the function should output something. Without the return statement, your function will return an object None.
123 |
124 | This is what was happening for the previous functions we wrote with the print statements. The None value represents a lack of a datatype.
125 |
126 | We can have multiple return values for a function as well.
127 |
128 | ```python
129 | def plus_one(number):
130 | return number + 1
131 |
132 | plus_one(number=3)
133 | ```
134 |
135 | ```
136 | def something(parameter):
137 | # your code goes here
138 | return value
139 | ```
140 |
141 | ```python
142 | def square(x):
143 | y = x ** 2
144 | return y
145 |
146 | result = square(3)
147 | print(result)
148 |
149 | ```
150 |
151 | ## Docstrings
152 | Docstrings help us document what the code does.
153 | ```python
154 | def plus_one(number):
155 | """Adds one to the number"""
156 | return number + 1
157 |
158 | print(plus_one(number=4))
159 | ```
160 |
161 | ## Local and Global Scope
162 | Variables assigned in a function are only local to that function. Variables assigned outside of all functions exist in the global scope. You can have variables named the same thing in different functions that are different variables.
163 |
164 | ```python
165 | import datetime
166 |
167 | time = datetime.datetime.now() # global
168 |
169 | def greeting(time):
170 | name = 'Jess' # local and temporary
171 | print('Hello {}, the time is {}'.format(name, time))
172 |
173 | # print(name)
174 | greeting(time=time)
175 | ```
176 |
177 | ```python
178 | import datetime
179 |
180 | time = datetime.datetime.now() # global
181 | name = 'James'
182 |
183 |
184 | def greeting(time):
185 | global name
186 | name = 'Jess'
187 | print('Hello {}, the time is {}'.format(name, time))
188 |
189 | print(name)
190 | greeting(time=time)
191 | print(name)
192 | ```
193 | ## Why Not Have Everything Be Global
194 |
195 | This allows us to separate out the code so that is easier for debugging. So if something is going wrong you can take a look at the function, instead of looking through the entire program.
196 |
197 | ## Main Functions
198 | Many other programming languages require a main function in order to execute. Including a main() function, though not required, can structure our Python programs in a logical way that puts the most important components of the program into one function. It can also make our programs easier for non-Python programmers to read.
199 |
200 | In Python, '__main__' is the name of the scope where top-level code will execute. When a program is run from standard input, a script, or from an interactive prompt, its __name__ is set equal to '__main__'.
201 |
202 | ```python
203 | def hello():
204 | print('Hello, World!')
205 |
206 | def main():
207 | print('This is the main function.')
208 | hello()
209 |
210 | # main()
211 |
212 | if __name__ == '__main__':
213 | main()
214 |
215 | # if __name__ == '__main__':
216 | # hello()
217 | ```
218 |
219 | ## Your Functions They Do Too Much
220 | To make your code more reusable and less error prone. Try to make it so your functions only do one thing at a time. This will allow your code to be more testable in the future.
221 |
--------------------------------------------------------------------------------
/Thursday Febuary 15th/Lectures/review.md:
--------------------------------------------------------------------------------
1 | # Review
2 |
3 | ## A note
4 | Make sure we are working in groups for the group activity. This is a way we can all as a class get better.
5 |
6 | ## Variables
7 | Variables are containers of information.
8 |
9 | ```python
10 | name = 'Jessica'
11 | age = 32
12 | city = 'Brooklyn'
13 | ```
14 |
15 | ## Data Types
16 | The three data types are as follows:
17 | - strings
18 | - integers
19 | - floating point numbers
20 |
21 | ## Quotes on strings
22 | You can use single or double quotes for strings. Triple quotes for long strings.
23 |
24 | ## Slicing
25 | A few folks had issues because they weren't slicing a string.
26 |
27 | ```python
28 | phone_number = '3017041328'
29 | area_code = phone_number[0:3]
30 | second_part = phone_number[3:6]
31 | third_part = phone_number[6:]
32 | format_num = '({})-{}-{}'.format(area_code, second_part, third_part)
33 | print(format_num)
34 | ```
35 |
36 | ## Input
37 | The input() function allows us to ask a question of a user. Keep in mind this always returns a string so if you need this to be another data type you will have to convert it.
38 |
39 | ## String Formatting
40 | String formatting is like mad libs. You can insert in variables into strings.
41 |
42 | ```python
43 | print('Hi {}, you are {} years old and you live in Brooklyn'.format(name, age, city))
44 | ```
45 |
46 | ## Conditionals
47 | ```
48 | if condition:
49 | do something
50 | elif other_condition:
51 | do something else
52 | else:
53 | do another thing
54 | ```
55 |
56 | ```python
57 | if raining == 'yes':
58 | print 'Better bring an umbrella!'
59 | elif raining == 'maybe later today':
60 | print 'Better bring an umbrella, just in case'
61 | else:
62 | print 'No umbrella today!'
63 | ```
64 |
65 | ## Python 2 instead of Python 3
66 | Some students had issues of having trouble with needing to type python3.6 instead of python. To correct this [I recommend setting up alias for it](https://stackoverflow.com/questions/18425379/how-to-set-pythons-default-version-to-3-3-on-os-x).
67 |
68 | ## Breaking Up Long Lines
69 | You can use \ to do so like this:
70 |
71 | ```python
72 | open(self.full_path, 'r') as input, \
73 | open(self.output_csv, 'ab') as output:
74 | ```
75 |
--------------------------------------------------------------------------------
/Thursday Febuary 15th/about.md:
--------------------------------------------------------------------------------
1 | # Thursday February 15th
2 | We'll get to take a look at how other people write code by checking out our homework. We'll come back together to review our last class and discuss advanced conditionals. We'll cover functions and than re-write our code from last week with functions.
3 |
4 | Slides for this class are found [here](http://jessicagarson.com/NYU-Intro-to-Python-Feb-15/).
5 |
6 | ## Agenda
7 | ### 6:30 - 6:45
8 | Homework Show and Tell
9 | ### 6:45 - 7:00
10 | Homework Number 2
11 | Review
12 | ### 7:00 - 7:30
13 | Advanced Conditionals and Functions
14 | ### 7:30 - 8:00
15 | Rewriting Your Code with Functions
16 |
17 | ## Homework Show and Tell
18 | We'll get started with reviewing our homework! Break up into groups of 5 - 6 and go around and discuss how you solved the homework assignment.
19 |
20 | ## How to Prep For Next Class
21 | We have another homework assignment that has been posted in assignments. For the next class, you will not need to prep but I will make sure to add a resources folder. So you have a good idea of where to find good resources.
22 |
--------------------------------------------------------------------------------
/Thursday Febuary 22nd/Actvities/PBJ_Time.md:
--------------------------------------------------------------------------------
1 | # Peanut Butter Jelly Time
2 |
3 | Today we're going to make some peanut butter and jelly sandwiches using functions.
4 |
5 | You need three ingredients to make a PB&J, so you'll want three different variables:
6 | - How much bread do you have? (make this a number that reflects how many slices of bread you have)
7 | - Each sandwich requires 2 slices of bread
8 | - How much peanut butter do you have? (make this a number that reflects how many sandwiches-worth of peanut butter you have)
9 | - How much jelly do you have? (make this a number that reflects how many sandwiches-worth of jelly you have)
10 |
11 | ## Part 1
12 | You will ask the user how much of each they have.
13 |
14 | ## Part 2
15 | How many full sandwiches do you have the resources to make?
16 |
17 | ## Part 3
18 | If there is leftover bread let the user know they can make an open faced sandwich with the leftover slice.
19 |
--------------------------------------------------------------------------------
/Thursday Febuary 22nd/Actvities/diagram_a_function.md:
--------------------------------------------------------------------------------
1 | ## Diagram a Function
2 |
3 | Write a function that takes the sum of three numbers. Make sure you comment out the parts of the function as I did in the example at the beginning of today's class.
4 |
--------------------------------------------------------------------------------
/Thursday Febuary 22nd/Actvities/rewrite_your_homework.md:
--------------------------------------------------------------------------------
1 | # Homework one with functions.
2 | Rewrite your homework but with functions if you aren't using them already.
3 |
--------------------------------------------------------------------------------
/Thursday Febuary 22nd/about.md:
--------------------------------------------------------------------------------
1 | # Thursday February
2 | We're going to review functions and practice writing functions.
3 |
4 | Slides are found [here](http://jessicagarson.com/NYU-Intro-to-Python-Feb-22/#/).
5 |
6 | ## Agenda
7 | ### 6:30 - 6:35
8 | A note on learning python in 2018
9 | ### 6:35 - 7:00
10 | Review of functions
11 | ### 7:00 - 8:00
12 | Working on activities
13 |
14 | ## A Note
15 | With many different resources out there and may different ways to learn how to code these days, it's very easy to find resources that teach in a different order than I do. We also all have different backgrounds and may have been exposed to a more advanced way of solving the problem. One of my favorite things about code is that there are many different ways to accomplish a goal. I know we all come from different backgrounds and that temptation to jump ahead can be great, but please try to practice and make sure we fully master a concept before trying things using concepts we haven't introduced yet. We are here to make sure we have a strong foundation that we'll later build off of. If you quickly master a concept, this is your opportunity to help out another student who might not.
16 |
17 | ## Outside Problems
18 | Right now is the best time to learn how to code, with hundreds of free resources at our fingers anyone can have the resources to become a developer and this is very exciting. This class is designed to cover the basics so we can conquer harder problems in the future. If you get lost with another resource, that's okay where we are now. However my job as your instructor for this class is to guide you on a journey as I have seen works the best for my students in the past and based on my own journey as a developer. As of today, I'll only be helping with problems as it relates to the assigned materials and concepts that we have covered in this class.
19 |
20 | ## Atom Shell Commands
21 | You might need to install shell commands for atom to make this work properly.
22 |
23 | ## A Note on Conditionals
24 | A note on conditionals. If we only have 2 conditionals, an if and an else is preferred.
25 |
26 | ```python
27 | if len(sentence) <= 280:
28 | print ('Congrats!, your sentence fits in a tweet')
29 | else:
30 | print ('Sorry, you need to trim your sentence')
31 | ```
32 |
33 | Try to avoid double if statements, and for multiple conditions use elif. This is the best practice for 3 or more conditions. You can have as many elifs as you need.
34 |
35 | ```
36 | if condition:
37 | do something
38 | elif other_condition:
39 | do something else
40 | elif another_condition:
41 | do something else too
42 | else:
43 | do another thing
44 | ```
45 |
46 | ## A Note on the Homework
47 | The homework is due Monday at 6:30pm. Please email me a .py file attached to an email.
48 |
49 | Since a few folks have asked about the make tags assignment. I figured I'd go over it.
50 |
51 | Your job is to create a function that looks something like this:
52 | ```
53 | def make_tags(tag, word):
54 | # your code here
55 | return formatted with tags around it
56 | ```
57 |
58 | So if you run make_tags('i', 'Yay') you will get the following:
59 | ```python
60 | make_tags('i', 'Yay')
61 | # result would be Yay
62 | ```
63 |
64 | ## How to Prep for the Next Class
65 | - [Loops Python Tutorial](https://www.datacamp.com/community/tutorials/loops-python-tutorial)
66 | - [Lists - Automate the Boring Stuff](https://automatetheboringstuff.com/chapter4/)
67 | - [Lists Dive into Python 3](http://www.diveintopython3.net/native-datatypes.html#lists)
68 |
--------------------------------------------------------------------------------
/Thursday Febuary 22nd/code/another_option.py:
--------------------------------------------------------------------------------
1 | # Define function to check if name contains a vowel
2 | def has_vowel():
3 | if set('aeiou').intersection(name.lower()):
4 | print('Your name contains a vowel.')
5 | else:
6 | print('Your name does not contain a vowel.')
7 |
8 |
9 | if __name__ == '__main__':
10 | name = str(input('Enter your name: '))
11 | print('The name you entered is {}'.format(name))
12 | has_vowel()
13 |
--------------------------------------------------------------------------------
/Thursday Febuary 22nd/code/global.py:
--------------------------------------------------------------------------------
1 | a = 6
2 |
3 |
4 | def oneplus():
5 | global a
6 | a = 1 + a
7 | return a
8 |
9 |
10 | def twoplus():
11 | global a
12 | a = 2 + a
13 | return a
14 |
15 |
16 | print(a) # 6
17 | print(oneplus()) # 7
18 | print(twoplus()) # 9
19 | print(a) # 9
20 |
--------------------------------------------------------------------------------
/Thursday Febuary 22nd/code/keywords.py:
--------------------------------------------------------------------------------
1 | def plus(a, b):
2 | return a + b
3 |
4 |
5 | print(plus(2, 3))
6 | print(plus(a=1, b=2))
7 |
--------------------------------------------------------------------------------
/Thursday Febuary 22nd/code/main.py:
--------------------------------------------------------------------------------
1 | name = str(input('Enter your name: '))
2 | print('The name you entered is {}'.format(name))
3 |
4 |
5 | # Define function to check if name contains a vowel
6 | def has_vowel():
7 | if set('aeiou').intersection(name.lower()):
8 | print('Your name contains a vowel.')
9 | else:
10 | print('Your name does not contain a vowel.')
11 |
12 |
13 | # Define main method that calls other functions
14 | def main():
15 | has_vowel()
16 |
17 |
18 | # Execute main() function
19 | if __name__ == '__main__':
20 | main # Code to run when this is the main program here.
21 |
--------------------------------------------------------------------------------
/Thursday Febuary 22nd/code/phone_numbers.py:
--------------------------------------------------------------------------------
1 | def number_formatted(phone_number):
2 | """Formats a phone number"""
3 | area_code = phone_number[0:3]
4 | second_part = phone_number[3:6]
5 | third_part = phone_number[6:]
6 | return '({})-{}-{}'.format(area_code, second_part, third_part)
7 |
8 |
9 | # print(second_part)
10 | print(number_formatted(phone_number="3017041328"))
11 |
--------------------------------------------------------------------------------
/Thursday Febuary 22nd/code/same_name.py:
--------------------------------------------------------------------------------
1 | name = 'Kelly'
2 |
3 |
4 | def hello():
5 | global name
6 | name = 'Jess'
7 | return 'Hello {}'.format(name)
8 |
9 |
10 | def hi():
11 | name = 'Alex'
12 | return 'Hi {}'.format(name)
13 |
14 |
15 | print(name) # Kelly
16 | print(hello()) # Hello Jess
17 | print(name) # Hello Jess
18 | print(hi()) # Hi Alex
19 |
--------------------------------------------------------------------------------
/Thursday Febuary 22nd/code/square.py:
--------------------------------------------------------------------------------
1 | def square(x): # Define the function
2 | """Returns the square of a number""" # Docstring
3 | y = x ** 2 # Body
4 | return y # Return Statement
5 |
6 |
7 | result = square(x=3) # Call the function
8 | print(result) # Print out the result
9 |
--------------------------------------------------------------------------------
/Thursday Febuary 22nd/review_of_functions.md:
--------------------------------------------------------------------------------
1 | # Review of Functions
2 |
3 | ## What are Functions?
4 | Functions are reusable bits of code. They allow us to repeat ourselves less and therefore prevent bugs.
5 |
6 | Functions have the following:
7 | - A def statement that allows us to define our function.
8 | - A body of our code we can write our code in it.
9 | - A return value - that gives us a value to save
10 |
11 | Functions take in parameters/arguments. Parameters are the variables inside the function. Arguments are the value passed into the function.
12 |
13 | Here is a program that finds the square of a number.
14 | ```python
15 | # Define the function
16 | def square(x): # Define the function
17 | """Returns the square of a number""" # Docstring
18 | y = x ** 2 # Body
19 | return y # Return Statement
20 |
21 |
22 | result = square(x=3) # Call the function
23 | print(result) # Print out the result
24 | ````
25 | In this example x is the variable inside of the function and therefore the parameter. 3 is the argument.
26 |
27 | ## Keyword Arguments
28 | You can set keyword arguments in 2 different ways. One just calling the the function with the arguments. Or by setting the parameter equal to the argument.
29 |
30 | ```python
31 | def plus(a,b):
32 | return a + b
33 |
34 | plus(2,3)
35 |
36 | plus(a=1, b=2)
37 | ```
38 |
39 | ## Local Variables
40 | For the following function the variables area_code, second_part, and third part are local variables. Meaning they can't be called outside of the function.
41 |
42 | ```python
43 | def number_formatted(phone_number):
44 | """Formats a phone number"""
45 | area_code = phone_number[0:3]
46 | second_part = phone_number[3:6]
47 | third_part = phone_number[6:]
48 | return '({})-{}-{}'.format(area_code, second_part, third_part)
49 |
50 |
51 | # print(second_part)
52 | print(number_formatted(phone_number="3017041328"))
53 | ```
54 |
55 | ## Global Scope
56 | In the example below since 6 was assigned outside a function it is in the local scope and we call in the global variable so that we can make changes to it in our program as a whole.
57 |
58 |
59 | ```python
60 | a = 6
61 |
62 |
63 | def oneplus():
64 | global a
65 | a = 1 + a
66 | return a
67 |
68 |
69 | def twoplus():
70 | global a
71 | a = 2 + a
72 | return a
73 |
74 |
75 | print(a)
76 | print(oneplus())
77 | print(twoplus())
78 | print(a)
79 | ```
80 |
81 | ## Variables Can Have The Same Names
82 |
83 | You can have 2 different variables in two different functions that have the same name.
84 |
85 | ```python
86 | def hello():
87 | name = 'Jess'
88 | return 'Hello {}'.format(name)
89 |
90 |
91 | def hi():
92 | name = 'Alex'
93 | return 'Hi {}'.format(name)
94 |
95 |
96 | print(hi())
97 | print(hello())
98 | ```
99 |
100 | ## The Main Function Tying It All Together
101 | The main function allows us to tie everything together and make our code a bit more readable.
102 |
103 | ```python
104 | name = str(input('Enter your name: '))
105 | print('The name you entered is {}'.format(name))
106 |
107 |
108 | # Define function to check if name contains a vowel
109 | def has_vowel():
110 | if set('aeiou').intersection(name.lower()):
111 | print('Your name contains a vowel.')
112 | else:
113 | print('Your name does not contain a vowel.')
114 |
115 |
116 | # Define main method that calls other functions
117 | def main():
118 | has_vowel()
119 |
120 |
121 | # Execute main() function
122 | if __name__ == '__main__':
123 | main()
124 | ```
125 |
126 | We also have some code at the end which tells our code to run. In Python, '__main__' is the name of the scope where top-level code will execute. When a program is run from standard input, a script, or from an interactive prompt, its __name__ is set equal to '__main__'.
127 |
128 | ```
129 | if __name__ == '__main__':
130 | # Code to run when this is the main program here.
131 | ```
132 |
133 | ## Another Option Without the Main Function
134 |
135 | We can also run this program without the main function like this. We also added some of the main instruction to the name block as well.
136 |
137 | ```python
138 | # Define function to check if name contains a vowel
139 | def has_vowel():
140 | if set('aeiou').intersection(name.lower()):
141 | print('Your name contains a vowel.')
142 | else:
143 | print('Your name does not contain a vowel.')
144 |
145 |
146 | if __name__ == '__main__':
147 | name = str(input('Enter your name: '))
148 | print('The name you entered is {}'.format(name))
149 | has_vowel()
150 | ```
151 |
--------------------------------------------------------------------------------
/Thursday Febuary 8th/about.md:
--------------------------------------------------------------------------------
1 | # Thursday February 8th
2 | Second class! We'll review our activity from last week, hear some advice for learning how to code, get started with Python, learn a bit about how to interact with our command line of our computer. We'll also introduce our first homework and final project.
3 |
4 | Slides for the class are found [here](http://jessicagarson.com/NYU-Intro-to-Python-Feb-8th/).
5 |
6 | ## Seating
7 | Middle school dance rules still, Macs sit with Macs and PCs sit with PCs.
8 |
9 | ## Agenda
10 | ### 6:30 - 6:40
11 | - Review from last class
12 | ### 6:40 - 6:45
13 | - Introduce homework assignment 1
14 | - Introduce our project for the class
15 | ### 6:45 - 7:00
16 | - Advice on how to learn how to code
17 | ### 7:00 - 7:10
18 | - Writing our first program
19 | - Running our first program
20 | ### 7:10 - 7:30
21 | - Command line basics
22 | ### 7:30 - 8:00
23 | - Command line activity
24 |
25 | ## What We Will Accomplish By The End of Class
26 | - We will review our last class
27 | - Learn about how to learn how to code
28 | - Get introduced to the class project and first assignments
29 | - Write our first program in python
30 | - Run our first program in python
31 | - Learn about command line basics
32 | - Play around with the command line
33 |
34 | ## How to Prep for Next Class
35 | - [Automate the Boring Stuff with Python Chapter 1](https://automatetheboringstuff.com/chapter1/)
36 | - [Automate the Boring Stuff with Python Chapter 2](https://automatetheboringstuff.com/chapter2/)
37 | - [Python Strings](https://developers.google.com/edu/python/strings)
38 | - [How To Do Math in Python 3 with Operators](https://www.digitalocean.com/community/tutorials/how-to-do-math-in-python-3-with-operators)
39 | - [How to Think Like a Computer Scientist: Learning with Python 3](http://openbookproject.net/thinkcs/python/english3e/conditionals.html)
40 |
--------------------------------------------------------------------------------
/Thursday Febuary 8th/group_actvities/command_line_activity.md:
--------------------------------------------------------------------------------
1 | # Command Line Activity
2 | In groups of 3 or so go through the following steps:
3 |
4 | - Create a new folder from the command line called created_from_the_command_line.
5 | - Inside the folder create a new file named yo.txt.
6 | - Inside the command line go to atom and edit yo.txt to include your favorite things that happened in the past week.
7 | - Rename yo.txt to a new name from the command line.
8 | - View and stream the file from the command line.
9 | - Create a new folder named delete_this_soon
10 | - Create 5 files inside of the folder
11 | - Delete those
12 | - Remove the folder delete_this_soon
13 |
--------------------------------------------------------------------------------
/Thursday Febuary 8th/group_actvities/hello_world.md:
--------------------------------------------------------------------------------
1 | # Hello World
2 | ## Create a new folder on your computer
3 | Call it `hello_world`
4 | ```bash
5 | cd hello_world
6 | ```
7 |
8 | ## Create a new file called hello.py
9 | Macs:
10 | ```bash
11 | touch hello.py
12 | ```
13 |
14 | PCs:
15 | ```bash
16 | New-Item new_file.txt -type file
17 | ```
18 |
19 | ## Open the folder in Atom
20 | ```bash
21 | atom .
22 | ```
23 |
24 | ## Edit the File to Say:
25 | ```python3
26 | print("Hello, World!")
27 | ```
28 |
29 | ## Run the File from the Command Line
30 | ```bash
31 | python hello.py
32 | ```
33 |
--------------------------------------------------------------------------------
/Thursday Febuary 8th/group_actvities/how_to_keep_your_fork_current.md:
--------------------------------------------------------------------------------
1 | # How to Keep a Fork Current
2 |
3 | ## Configure your environment with your GitHub user info
4 | Use the directions found [here](https://services.github.com/on-demand/github-cli/git-configuration) to make sure you have your environment set with your GitHub information.
5 |
6 | ## 1. Clone your fork:
7 |
8 | You will need to first clone your fork which brings your fork from your github into your own computer.
9 |
10 | ```
11 | git clone git@github.com:YOUR-USERNAME/YOUR-FORKED-REPO.git
12 | ```
13 |
14 | ## 2. Add remote from original repository in your forked repository:
15 |
16 | ```
17 | cd into/cloned/fork-repo
18 | git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
19 | git fetch upstream
20 | git checkout master
21 | git merge/upstream master
22 | git push
23 | ```
24 |
25 | ## 3. Updating your fork from original repo to keep up with their changes:
26 |
27 | ```
28 | git pull upstream master
29 | ```
30 |
--------------------------------------------------------------------------------
/Thursday Febuary 8th/live_code.md:
--------------------------------------------------------------------------------
1 | # Live Code - The Command Line
2 |
3 | ## Let's First Confirm Set Up
4 | Go to your terminal or powershell and type python. If you don't see something similar to my screen come find me after class. After we are done let's exit. This is how to get into what's known as the interactive interpreter.
5 |
6 | ```bash
7 | python
8 | exit()
9 | ```
10 |
11 | ## This Might Look Familiar
12 | If you are older, this might remind of you the old set up of a computer. This means you have a leg up for today's class.
13 |
14 | ## A New Way to Interact With Your Computer
15 | Instead of interacting with your computer via finder on a Mac or File Explorer. We can use commands.
16 |
17 | ## Where Am I?
18 | Print working directory.
19 | ```bash
20 | pwd
21 | ```
22 |
23 | ## Take Me Back
24 | How to Go Back to The Top Level Directory
25 | ```bash
26 | cd ~
27 | ```
28 |
29 | ## Change Directory
30 | Let's go to the documents directory.
31 | ```bash
32 | cd documents
33 | ```
34 |
35 | ## Make A New Directory
36 | To make a new directory we'll use `mkdir` to do so.
37 | ```bash
38 | mkdir class_demo
39 | ```
40 |
41 | ## You Can Also Make Directories Inside of Directories
42 | ```bash
43 | mkdir class_demo/demo_1
44 | mkdir class_demo/files_for_demo
45 | ```
46 |
47 | ## Go Up One Directory
48 | `cd ..` allows us to go up one directory.
49 | ```bash
50 | cd ..
51 | pwd
52 | ```
53 |
54 | ## Remove a Directory
55 | This is one case where it depends on your computer how you can remove a directory.
56 |
57 | For windows:
58 | ```bash
59 | rmdir demo_1
60 | ```
61 |
62 | For macs:
63 | ```bash
64 | rm -rf demo_1
65 | ```
66 |
67 | ## Create a New File
68 |
69 | For PCs:
70 | ```bash
71 | pwd
72 | New-Item new_file.txt -type file
73 | New-Item hello.txt -type file
74 | ```
75 |
76 | For Macs:
77 | ```bash
78 | pwd
79 | touch new_file.txt
80 | touch hello.txt
81 | ```
82 |
83 | ## Remove a File
84 | ```bash
85 | rm new_file.txt
86 | ```
87 |
88 | ## Move a File
89 | This is also how you rename a file.
90 |
91 | ```bash
92 | pwd
93 | mv hello.txt whatsup.txt
94 | mv whatsup.txt files_for_demo/whatsup.txt
95 | ```
96 |
97 | ## Let's Open Atom From The Command Line
98 | ```bash
99 | atom .
100 | ```
101 |
102 | ## Let's Edit It
103 | The file will now say - Hello what's up?
104 |
105 | ## Copy a file
106 | ```
107 | cp whatsup.txt heywhatsup.txt
108 | ```
109 |
110 | ## View a file
111 |
112 | Macs:
113 |
114 | ```
115 | less heywhatsup.txt
116 | ```
117 |
118 | Press q to quit this interface
119 |
120 | PCs:
121 | ```
122 | more heywhatsup.txt
123 | ```
124 |
125 | ## Stream a File
126 | ```
127 | cat heywhatsup.txt
128 | ```
129 |
130 | ## Resources
131 | - [Linux](https://opensource.com/resources/linux)
132 | - [Bash Cheatsheet](https://learncodethehardway.org/unix/bash_cheat_sheet.pdf)
133 |
--------------------------------------------------------------------------------
/Thursday March 15th/about.md:
--------------------------------------------------------------------------------
1 | # Thursday March 15th
2 | All things files! Today we are going to dive into our files.
3 |
4 | ## Agenda
5 | ### 6:30 - 6:45
6 | Review
7 | ### 6:45 - 7:45
8 | File Handling
9 | os
10 | Pandas
11 | ### 7:45 - 8pm
12 | Pair Programming
13 |
14 | ## Homework due Monday
15 | Homework 4 is due Monday. Send me a link to your repository by the start of class.
16 |
17 | ## Office Hours Update
18 | - A change to tomorrow's office hours - 9 - 11am instead of 9 - 12 at Stonefruit.
19 | - 9 - 11am - Stonefruit 1058 Bedford Ave, Brooklyn, NY 11205
20 | - 4 - 7pm - Think Coffee 248 Mercer St, New York, NY 10012
21 |
22 | ## How to Prep for Next Class
23 | - [Improve Your Python: Python Classes and Object Oriented Programming](https://jeffknupp.com/blog/2014/06/18/improve-your-python-python-classes-and-object-oriented-programming/)
24 | - [Object Oriented Programming Python](https://www.digitalocean.com/community/tutorial_series/object-oriented-programming-in-python-3)
25 | - [Iterators and Classes](http://www.diveintopython3.net/iterators.html)
26 | - [How To Construct Classes and Define Objects in Python 3](https://www.digitalocean.com/community/tutorials/how-to-construct-classes-and-define-objects-in-python-3)
27 |
--------------------------------------------------------------------------------
/Thursday March 15th/code_and_files/.ipynb_checkpoints/Untitled-checkpoint.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [],
3 | "metadata": {},
4 | "nbformat": 4,
5 | "nbformat_minor": 2
6 | }
7 |
--------------------------------------------------------------------------------
/Thursday March 15th/code_and_files/.ipynb_checkpoints/file handling-checkpoint.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [],
3 | "metadata": {},
4 | "nbformat": 4,
5 | "nbformat_minor": 2
6 | }
7 |
--------------------------------------------------------------------------------
/Thursday March 15th/code_and_files/.ipynb_checkpoints/os-checkpoint.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [],
3 | "metadata": {},
4 | "nbformat": 4,
5 | "nbformat_minor": 2
6 | }
7 |
--------------------------------------------------------------------------------
/Thursday March 15th/code_and_files/.ipynb_checkpoints/pandas-checkpoint.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [],
3 | "metadata": {},
4 | "nbformat": 4,
5 | "nbformat_minor": 2
6 | }
7 |
--------------------------------------------------------------------------------
/Thursday March 15th/code_and_files/.ipynb_checkpoints/pandas_demo-checkpoint.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [],
3 | "metadata": {},
4 | "nbformat": 4,
5 | "nbformat_minor": 2
6 | }
7 |
--------------------------------------------------------------------------------
/Thursday March 15th/code_and_files/Untitled.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "code",
5 | "execution_count": null,
6 | "metadata": {},
7 | "outputs": [],
8 | "source": []
9 | }
10 | ],
11 | "metadata": {
12 | "kernelspec": {
13 | "display_name": "Python 3",
14 | "language": "python",
15 | "name": "python3"
16 | },
17 | "language_info": {
18 | "codemirror_mode": {
19 | "name": "ipython",
20 | "version": 3
21 | },
22 | "file_extension": ".py",
23 | "mimetype": "text/x-python",
24 | "name": "python",
25 | "nbconvert_exporter": "python",
26 | "pygments_lexer": "ipython3",
27 | "version": "3.6.4"
28 | }
29 | },
30 | "nbformat": 4,
31 | "nbformat_minor": 2
32 | }
33 |
--------------------------------------------------------------------------------
/Thursday March 15th/code_and_files/clean_name_score.csv:
--------------------------------------------------------------------------------
1 | ,name,Score,Name
2 | 0,Tom,75,Tom
3 | 1,Sam,95,Sam
4 | 2,James ,98,James
5 | 3,Tina,74,Tina
6 | 4,Becca,80,Becca
7 | 5,Dessa ,83,Dessa
8 | 6,Lena,56,Lena
9 |
--------------------------------------------------------------------------------
/Thursday March 15th/code_and_files/cleaned_name_score.csv:
--------------------------------------------------------------------------------
1 | ,Name,Score
2 | 0,Tom,75
3 | 1,Sam,95
4 | 2,James,98
5 | 3,Tina,74
6 | 4,Becca,80
7 | 5,Dessa,83
8 | 6,Lena,56
9 |
--------------------------------------------------------------------------------
/Thursday March 15th/code_and_files/file handling.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "code",
5 | "execution_count": 1,
6 | "metadata": {},
7 | "outputs": [],
8 | "source": [
9 | "with open('states.txt', 'r') as states_file:\n",
10 | " states = states_file.read()"
11 | ]
12 | },
13 | {
14 | "cell_type": "code",
15 | "execution_count": 2,
16 | "metadata": {},
17 | "outputs": [
18 | {
19 | "name": "stdout",
20 | "output_type": "stream",
21 | "text": [
22 | "Alabama\n",
23 | "Alaska\n",
24 | "Arizona\n",
25 | "Arkansas\n",
26 | "California\n",
27 | "Colorado\n",
28 | "Connecticut\n",
29 | "Delaware\n",
30 | "District Of Columbia\n",
31 | "Florida\n",
32 | "Georgia\n",
33 | "Hawaii\n",
34 | "Idaho\n",
35 | "Illinois\n",
36 | "Indiana\n",
37 | "Iowa\n",
38 | "Kansas\n",
39 | "Kentucky\n",
40 | "Louisiana\n",
41 | "Maine\n",
42 | "Maryland\n",
43 | "Massachusetts\n",
44 | "Michigan\n",
45 | "Minnesota\n",
46 | "Mississippi\n",
47 | "Missouri\n",
48 | "Montana\n",
49 | "Nebraska\n",
50 | "Nevada\n",
51 | "New Hampshire\n",
52 | "New Jersey\n",
53 | "New Mexico\n",
54 | "New York\n",
55 | "North Carolina\n",
56 | "North Dakota\n",
57 | "Ohio\n",
58 | "Oklahoma\n",
59 | "Oregon\n",
60 | "Pennsylvania\n",
61 | "Rhode Island\n",
62 | "South Carolina\n",
63 | "South Dakota\n",
64 | "Tennessee\n",
65 | "Texas\n",
66 | "Utah\n",
67 | "Vermont\n",
68 | "Virginia\n",
69 | "Washington\n",
70 | "West Virginia\n",
71 | "Wisconsin\n",
72 | "Wyoming\n",
73 | "\n"
74 | ]
75 | }
76 | ],
77 | "source": [
78 | "print(states)"
79 | ]
80 | },
81 | {
82 | "cell_type": "code",
83 | "execution_count": 3,
84 | "metadata": {},
85 | "outputs": [],
86 | "source": [
87 | "with open('states.txt', 'r') as states_file:\n",
88 | " state_list = states_file.read().split('\\n')"
89 | ]
90 | },
91 | {
92 | "cell_type": "code",
93 | "execution_count": 4,
94 | "metadata": {},
95 | "outputs": [
96 | {
97 | "name": "stdout",
98 | "output_type": "stream",
99 | "text": [
100 | "['Alabama', 'Alaska', 'Arizona', 'Arkansas', 'California', 'Colorado', 'Connecticut', 'Delaware', 'District Of Columbia', 'Florida', 'Georgia', 'Hawaii', 'Idaho', 'Illinois', 'Indiana', 'Iowa', 'Kansas', 'Kentucky', 'Louisiana', 'Maine', 'Maryland', 'Massachusetts', 'Michigan', 'Minnesota', 'Mississippi', 'Missouri', 'Montana', 'Nebraska', 'Nevada', 'New Hampshire', 'New Jersey', 'New Mexico', 'New York', 'North Carolina', 'North Dakota', 'Ohio', 'Oklahoma', 'Oregon', 'Pennsylvania', 'Rhode Island', 'South Carolina', 'South Dakota', 'Tennessee', 'Texas', 'Utah', 'Vermont', 'Virginia', 'Washington', 'West Virginia', 'Wisconsin', 'Wyoming', '']\n"
101 | ]
102 | }
103 | ],
104 | "source": [
105 | "print(state_list)"
106 | ]
107 | },
108 | {
109 | "cell_type": "code",
110 | "execution_count": 5,
111 | "metadata": {},
112 | "outputs": [],
113 | "source": [
114 | "with open('name_score.csv', 'r') as f:\n",
115 | " name_score = f.read()"
116 | ]
117 | },
118 | {
119 | "cell_type": "code",
120 | "execution_count": 6,
121 | "metadata": {},
122 | "outputs": [
123 | {
124 | "name": "stdout",
125 | "output_type": "stream",
126 | "text": [
127 | "Name ,Score\n",
128 | "Tom,75\n",
129 | "Sam,95\n",
130 | "James ,98\n",
131 | "Tina,74\n",
132 | "Becca,80\n",
133 | "Dessa ,83\n",
134 | "Lena,56\n"
135 | ]
136 | }
137 | ],
138 | "source": [
139 | "print(name_score)"
140 | ]
141 | },
142 | {
143 | "cell_type": "code",
144 | "execution_count": 7,
145 | "metadata": {},
146 | "outputs": [
147 | {
148 | "name": "stdout",
149 | "output_type": "stream",
150 | "text": [
151 | "75\n",
152 | "95\n",
153 | "98\n",
154 | "74\n",
155 | "80\n",
156 | "83\n",
157 | "56\n"
158 | ]
159 | }
160 | ],
161 | "source": [
162 | "import csv \n",
163 | "with open('name_score.csv') as csvfile: \n",
164 | " reader = csv.DictReader(csvfile)\n",
165 | " for row in reader:\n",
166 | " print(row['Score'])"
167 | ]
168 | },
169 | {
170 | "cell_type": "code",
171 | "execution_count": 8,
172 | "metadata": {},
173 | "outputs": [],
174 | "source": [
175 | "with open('file.txt', 'w') as f:\n",
176 | " f.write('This file now exists!')\n",
177 | " f.close()"
178 | ]
179 | },
180 | {
181 | "cell_type": "code",
182 | "execution_count": 9,
183 | "metadata": {},
184 | "outputs": [],
185 | "source": [
186 | "with open('turtles.txt', 'w') as f:\n",
187 | " f.write('Family of baby turtles')\n",
188 | " f.close()\n",
189 | " "
190 | ]
191 | },
192 | {
193 | "cell_type": "code",
194 | "execution_count": null,
195 | "metadata": {},
196 | "outputs": [],
197 | "source": []
198 | },
199 | {
200 | "cell_type": "code",
201 | "execution_count": null,
202 | "metadata": {},
203 | "outputs": [],
204 | "source": []
205 | }
206 | ],
207 | "metadata": {
208 | "kernelspec": {
209 | "display_name": "Python 3",
210 | "language": "python",
211 | "name": "python3"
212 | },
213 | "language_info": {
214 | "codemirror_mode": {
215 | "name": "ipython",
216 | "version": 3
217 | },
218 | "file_extension": ".py",
219 | "mimetype": "text/x-python",
220 | "name": "python",
221 | "nbconvert_exporter": "python",
222 | "pygments_lexer": "ipython3",
223 | "version": "3.6.4"
224 | }
225 | },
226 | "nbformat": 4,
227 | "nbformat_minor": 2
228 | }
229 |
--------------------------------------------------------------------------------
/Thursday March 15th/code_and_files/file.txt:
--------------------------------------------------------------------------------
1 | This file now exists!
--------------------------------------------------------------------------------
/Thursday March 15th/code_and_files/name_score.csv:
--------------------------------------------------------------------------------
1 | Name ,Score
2 | Tom,75
3 | Sam,95
4 | James ,98
5 | Tina,74
6 | Becca,80
7 | Dessa ,83
8 | Lena,56
--------------------------------------------------------------------------------
/Thursday March 15th/code_and_files/pandas_demo.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "code",
5 | "execution_count": 18,
6 | "metadata": {},
7 | "outputs": [],
8 | "source": [
9 | "import pandas as pd"
10 | ]
11 | },
12 | {
13 | "cell_type": "code",
14 | "execution_count": 19,
15 | "metadata": {},
16 | "outputs": [],
17 | "source": [
18 | "df = pd.read_csv('name_score.csv')"
19 | ]
20 | },
21 | {
22 | "cell_type": "code",
23 | "execution_count": 20,
24 | "metadata": {},
25 | "outputs": [
26 | {
27 | "data": {
28 | "text/html": [
29 | "
"
324 | ],
325 | "text/plain": [
326 | " Name Score\n",
327 | "0 Tom 75\n",
328 | "1 Sam 95\n",
329 | "2 James 98\n",
330 | "3 Tina 74\n",
331 | "4 Becca 80\n",
332 | "5 Dessa 83\n",
333 | "6 Lena 56"
334 | ]
335 | },
336 | "execution_count": 27,
337 | "metadata": {},
338 | "output_type": "execute_result"
339 | }
340 | ],
341 | "source": [
342 | "df"
343 | ]
344 | },
345 | {
346 | "cell_type": "code",
347 | "execution_count": 28,
348 | "metadata": {},
349 | "outputs": [],
350 | "source": [
351 | "df.columns = [\n",
352 | " 'name',\n",
353 | " 'Score'\n",
354 | "]"
355 | ]
356 | },
357 | {
358 | "cell_type": "code",
359 | "execution_count": null,
360 | "metadata": {},
361 | "outputs": [],
362 | "source": []
363 | },
364 | {
365 | "cell_type": "code",
366 | "execution_count": null,
367 | "metadata": {},
368 | "outputs": [],
369 | "source": []
370 | }
371 | ],
372 | "metadata": {
373 | "kernelspec": {
374 | "display_name": "Python 3",
375 | "language": "python",
376 | "name": "python3"
377 | },
378 | "language_info": {
379 | "codemirror_mode": {
380 | "name": "ipython",
381 | "version": 3
382 | },
383 | "file_extension": ".py",
384 | "mimetype": "text/x-python",
385 | "name": "python",
386 | "nbconvert_exporter": "python",
387 | "pygments_lexer": "ipython3",
388 | "version": "3.6.4"
389 | }
390 | },
391 | "nbformat": 4,
392 | "nbformat_minor": 2
393 | }
394 |
--------------------------------------------------------------------------------
/Thursday March 15th/code_and_files/states.txt:
--------------------------------------------------------------------------------
1 | Alabama
2 | Alaska
3 | Arizona
4 | Arkansas
5 | California
6 | Colorado
7 | Connecticut
8 | Delaware
9 | District Of Columbia
10 | Florida
11 | Georgia
12 | Hawaii
13 | Idaho
14 | Illinois
15 | Indiana
16 | Iowa
17 | Kansas
18 | Kentucky
19 | Louisiana
20 | Maine
21 | Maryland
22 | Massachusetts
23 | Michigan
24 | Minnesota
25 | Mississippi
26 | Missouri
27 | Montana
28 | Nebraska
29 | Nevada
30 | New Hampshire
31 | New Jersey
32 | New Mexico
33 | New York
34 | North Carolina
35 | North Dakota
36 | Ohio
37 | Oklahoma
38 | Oregon
39 | Pennsylvania
40 | Rhode Island
41 | South Carolina
42 | South Dakota
43 | Tennessee
44 | Texas
45 | Utah
46 | Vermont
47 | Virginia
48 | Washington
49 | West Virginia
50 | Wisconsin
51 | Wyoming
52 |
--------------------------------------------------------------------------------
/Thursday March 15th/code_and_files/turtles.txt:
--------------------------------------------------------------------------------
1 | Family of baby turtles
--------------------------------------------------------------------------------
/Thursday March 15th/code_and_files/write_a_message.py:
--------------------------------------------------------------------------------
1 | # let's write a .txt file with a fun message
2 |
3 | # let's read that file in
4 |
--------------------------------------------------------------------------------
/Thursday March 15th/lectures/file_handling.md:
--------------------------------------------------------------------------------
1 | # File handling
2 |
3 | ## Basic syntax
4 | ```python
5 | with open('states.txt', 'r') as states_file:
6 | states = states_file.read()
7 |
8 | print(states)
9 | ```
10 | What does this code do?
11 |
12 | - You might notice a new word we haven't seen yet, with. With is a keyword that tells Python we're going to do something with a file we're about to open.
13 | - When all commands within the indentation have been run, the file is closed automatically.
14 | - open() is a built-in function that tells Python to open a file.
15 | - It takes two arguments, a file name and a mode. he "mode" to open the file in, as a string.
16 | - The different modes are as follows:
17 | 1. 'r' : use for reading
18 | 2. 'w' : use for writing
19 | 3. 'x' : use for creating and writing to a new file
20 | 4. 'a' : use for appending to a file
21 | 5. 'r+' : use for reading and writing to the same file
22 | - The as keyword creates a variable for your file handler. The variable in this example is states_file, but you could use any variable name you want.
23 | - read() is a file method — a function that only works with file handlers. In this example, the file handler is states_file. .read() will read the entire contents of the file. In line 2 above, I've saved it into the variable states.
24 |
25 | We can turn this into a list. Using .split()
26 |
27 | ```python
28 | with open('states.txt', 'r') as states_file:
29 | state_list = states_file.read().split('\n')
30 |
31 | print(state_list)
32 | ```
33 | ## What about if we have a csv file?
34 | Can we use the same syntax here?
35 | ```python
36 | with open('name_score.csv', 'r') as f:
37 | name_score = f.read()
38 | print(name_score)
39 | ```
40 |
41 | ## DictReader
42 | The DictReader class basically creates a CSV object that behaves like a Python OrderedDict. It works by reading in the first line of the CSV and using each comma separated value in this line as a dictionary key. The columns in each subsequent row then behave like dictionary values and can be accessed with the appropriate key.
43 | ```python
44 | import csv
45 | with open('name_score.csv') as csvfile:
46 | reader = csv.DictReader(csvfile)
47 | for row in reader:
48 | print(row[Score])
49 | ```
50 |
51 | ## Writing files
52 | ```python
53 | with open('file.txt', 'w') as f:
54 | f.write('This file now exists!')
55 | f.close()
56 | ```
57 | In this code we are creating a file if it doesn't already exist. We are writing a the contents of the file and closing the connection to the file.
58 |
--------------------------------------------------------------------------------
/Thursday March 15th/lectures/how_the_internet_works.md:
--------------------------------------------------------------------------------
1 | ## Internet!
2 | What is it?
3 | - The Internet is basically just a marriage of hardware and protocols.
4 | - ARPANET - the grandfather to the internet. It’s just a network but the internet is a internet of internets. This started in the 1970s.
5 | - The internet is always changing as new networks come and old ones go. There are satellite networks and land networks connected via submarine cables. This can be even as small as a home network, or local area network (like an office).
6 | - The difference between the web and the internet.
7 |
8 | ## Clients and Servers
9 | - The internet is made up of two types of machines clients and server. Every machine is ether a client or a server but many machines can be both.
10 | - The client requests information from a server. The client starts with the local server and goes to a regional and than national server. It goes up the chain until it gets the information you need is.
11 | - A server is a computer program or a device that provides functionality for other programs or devices(clients).
12 | - When the information is being sent it needs to broken into many small pieces which are called packet. Packets don't always go in order and sometimes the same packets are sent separately in different places. Packets are reassembled based on the instructions that get sent.
13 | - When you go to a website what happens?
14 | The domain name system (DNS) translates hostnames such as (www.google.com) the ip address to a domain name. This happens via an DNS resolver.
15 |
16 | ## Requests
17 | We use requests everyday:
18 | - When you view a tweet you use the GET method.
19 | - When you write a tweet you use the POST method.
20 | - When you delete a tweet you use the DELETE method.
21 |
22 | ## Other types of Requests
23 | - HEAD - Same as GET but returns only HTTP headers and no document body
24 | - PUT - Uploads a representation of the specified URI
25 | - DELETE - Deletes the specified resource
26 | - OPTIONS - Returns the HTTP methods that the server supports
27 | - CONNECT - Converts the request connection to a transparent TCP/IP tunnel
28 |
29 | ## HTTP Messages
30 | - 100 level - Information
31 | - 200 level - Successful
32 | - 300 level - Redirection
33 | - 400 level - Client Error
34 | - 500 level - Server Errors
35 |
36 | ## A really great podcast on this
37 | [How does the internet work?](https://www.codenewbie.org/podcast/how-does-the-internet-work)
38 |
--------------------------------------------------------------------------------
/Thursday March 15th/lectures/os.md:
--------------------------------------------------------------------------------
1 | # The os library
2 | The os library in python allows us to interact with our operating system.
3 |
4 | ## Interacting with our os
5 | Remember the second class where we got to know the command line let's do this with python
6 |
7 | ## Where are we
8 | The pwd equivalent is as follows:
9 | ```python
10 | import os
11 |
12 | current_directory = os.getcwd()
13 | print(os.getcwd()) # equivalent to pwd
14 | ```
15 |
16 | ## Let's go up a directory
17 | Remember cd .. that allows us to up a directory. Let's do this with python.
18 | ```python
19 | os.chdir("..") # equivalent to cd ..
20 | print(os.getcwd())
21 | os.chdir(current_directory)
22 | print(os.getcwd())
23 | ```
24 |
25 | ## Is this file or a directory
26 | ```python
27 | print(os.path.isdir("file.txt"))
28 | print(os.path.isfile("file.txt"))
29 | ```
30 | ## Glob for pattern matching
31 | The glob library allows us to match files
32 | ```python
33 | from glob import glob
34 | ```
35 |
36 | ## Let's go through our files
37 | Let's see all our text files
38 | ```python
39 | files = glob("*.txt")
40 | print(files)
41 | first_file = open(files[0], "r")
42 | contents_one = first_file.read()
43 | print(contents_one)
44 | second_file = open(files[1], "r")
45 | print(contents_two)
46 | ```
47 |
48 | ## Let's scan the directory
49 | We can use the os.scandir to quickly list the files and folders in the directory.
50 | ```python
51 | folders = []
52 | files = []
53 |
54 | for entry in os.scandir('/Users/jessicagarson/Documents/NYU-Intro-to-Python-Spring-2018/Thursday March 15th/code_and_files'):
55 | if entry.is_dir():
56 | folders.append(entry.path)
57 | elif entry.is_file():
58 | files.append(entry.path)
59 |
60 | print('Folders:\n{}'.format(folders))
61 | print('Files:\n{}'.format(files))
62 | ```
63 |
--------------------------------------------------------------------------------
/Thursday March 15th/lectures/pandas.md:
--------------------------------------------------------------------------------
1 | # Pandas
2 | So what is Pandas?
3 |
4 | Pandas is a python library that allows for flexible data structures that makes data manipulation, file input, file output data cleaning, and simple computation easy.
5 |
6 | For our purposes it makes working with csv and excel files really easy.
7 |
8 | ## How do I start?
9 | To start you will need to install pandas.
10 | ```bash
11 | pip install pandas
12 | ```
13 |
14 | It's easier to see what's going inside of jupyter notebook. So you will need to install it and launch a notebook.
15 | ```bash
16 | pip install jupyter
17 | jupyter notebook
18 | ```
19 |
20 | Once we have our notebook running we'll need to import the library of pandas in.
21 | ```python
22 | import pandas as pd
23 | ```
24 |
25 | ## Yo Jess, What's that as, what does it do?
26 | The as allows us to name an alias so it's easier to work with so we don't have to type pandas all the time.
27 |
28 | ## Reading flies in
29 | To read files in we will use the method read_csv() to read in our file. Here we are reading in our file and saving it to a variable named df.
30 |
31 | ```python
32 | df = pd.read_csv('name_score.csv')
33 | ```
34 |
35 | For excel we would use the following syntax:
36 | ```python
37 | read_excel('filename.xlsx')
38 | ```
39 |
40 | ## DataFrames the heart of pandas.
41 | So you might have noticed that we named our variable df which is shorthand for data frame.
42 |
43 | If you come from R, you might remember that a data frame in R is where each row of these grids corresponds to measurements or values of an instance, while each column is a vector containing data for a specific variable. This means that a data frame’s rows do not need to contain, but can contain, the same type of values: they can be numeric, character, logical, etc.
44 |
45 | A data frame in pandas is similar. DataFrame is a 2-dimensional labeled data structure with columns of potentially different types. Similar to a spreadsheet or a SQL table.
46 |
47 | # Let's make sure we loaded in our data correctly.
48 | We can view the first 5 lines of our data by viewing the head of the DataFrame.
49 |
50 | ```python
51 | df.head()
52 | ```
53 |
54 | ## Describe
55 | This gives you descriptive statistics in a quick one line of code.
56 | ```python
57 | df.describe()
58 | ```
59 |
60 | ## Shape
61 | Shape returns a tuple containing the shape of the DataFrame.
62 | ```python
63 | df.shape
64 | ```
65 |
66 | ## Columns
67 | We can see the columns with df.columns.
68 | ```python
69 | df.columns
70 | ```
71 | To rename the column with the trailing space we can use this code.
72 | ```python
73 | df.rename(columns={'Name ':'name'}, inplace=True)
74 | ```
75 |
76 | ## Clean up the trailing spaces.
77 | ```python
78 | df['Name'] = df['Name'].str.strip()
79 | ```
80 |
81 | ## Send to a csv
82 | To send the python to a csv we can use this code:
83 | ```python
84 | df.to_csv('cleaned_name_score.csv')
85 | ```
86 |
87 | ## What's the mean for scores?
88 | Let's run this code to find out
89 | ```python
90 | df['Score'].mean()
91 | ```
92 |
--------------------------------------------------------------------------------
/Thursday March 15th/lectures/review.md:
--------------------------------------------------------------------------------
1 | ## Review
2 | We're going to review some recent concepts we've covered.
3 |
4 | ## Git
5 | - Git vs GitHub
6 | - Clone vs Forking
7 |
8 | ## How do we add files
9 | ```
10 | git status
11 | git add
12 | git status
13 | git commit -m "adding new file"
14 | git status
15 | git push
16 | ```
17 |
18 | ## What are virtualenvs
19 | They are a fresh start without the weight of the baggage of your computer so you can install packages in isolation.
20 |
21 | For macs:
22 | ```
23 | virtualenv newvenv
24 | source newvenv/bin/activate
25 | ```
26 | For PCs:
27 | ```
28 | virtualenv newenv
29 | source first_env/Scripts/activate
30 | ```
31 |
32 | Another option:
33 | ```
34 | virtualenv newenv
35 | . .\newenv\Scripts\activate.ps1
36 | ```
37 | If you get a permission error while running this. Try this:
38 | ```
39 | Set-ExecutionPolicy RemoteSigned
40 | ```
41 |
--------------------------------------------------------------------------------
/Thursday March 15th/pair_programming.md:
--------------------------------------------------------------------------------
1 | # Pair programming
2 | ## Create a file
3 | In a jupyter notebook, create a file with a message you want to say.
4 |
5 | ## Create your dataset
6 | In excel or google sheets create a data set with the headers: names, number of pets. Ask your partner and 5 other students for how many pets they have.
7 |
8 | Save this file as 'students_pets.csv' and move it into the directory where you are running your jupyter notebook.
9 |
10 | ## Load this dataset into pandas
11 | Let me know the average number of pets for the dataset you have.
12 |
13 | Hint:
14 | ```python
15 | df['num_of_pets'].mean()
16 | ```
17 |
18 | ## Take a look at the descriptive statistics for your dataset
19 | Let's take a look at the stats for it.
20 |
--------------------------------------------------------------------------------
/Thursday March 1st/about.md:
--------------------------------------------------------------------------------
1 | # Thursday March 1st
2 | We're going to take some today and make sure we have our basic concepts covered before we move forward to more difficult content. Slides are found [here](http://jessicagarson.com/NYU-Intro-to-Python-March-1/)
3 |
4 | ## Agenda
5 | ### 6:30 - 6:45
6 | Introduce Homework # 3
7 | Review of Python Concepts Covered
8 | ### 6:45 - 7:00
9 | Advanced Loops
10 | ### 7:00 - 7:40
11 | HackerRank Problems
12 | ### 7:40 - 8:00
13 | Debugging Hard Problems
14 |
15 | ## What is HackerRank
16 | [HackerRank](https://www.hackerrank.com) is a site that has programming challenges. Many skills tests for interviews use programs inspired by these sorts of problems.
17 |
18 | ## How to Prep for the Next Class
19 | -[Tuples](https://www.digitalocean.com/community/tutorials/understanding-tuples-in-python-3)
20 | -[Dictionaries](https://www.digitalocean.com/community/tutorials/understanding-dictionaries-in-python-3)
21 | -[Chapter 2 Dive Into Python 3](http://www.diveintopython3.net/native-datatypes.html)
22 | -[Chapter 4 Automate the Boring Stuff](https://automatetheboringstuff.com/chapter4/)
23 |
--------------------------------------------------------------------------------
/Thursday March 1st/code/break.py:
--------------------------------------------------------------------------------
1 | number = 0
2 |
3 | for number in range(10):
4 | number = number + 1
5 |
6 | if number == 5:
7 |
8 | break # break here
9 |
10 | print('Number is {}'.format(number))
11 |
12 | print('Out of loop')
13 |
--------------------------------------------------------------------------------
/Thursday March 1st/code/continue.py:
--------------------------------------------------------------------------------
1 | number = 0
2 |
3 | for number in range(10):
4 | number = number + 1
5 |
6 | if number == 5:
7 |
8 | continue # continue here
9 |
10 | print('Number is {}'.format(number))
11 |
12 | print('Out of loop')
13 |
--------------------------------------------------------------------------------
/Thursday March 1st/code/count.py:
--------------------------------------------------------------------------------
1 | count = 0
2 | while count < 5:
3 | print(count)
4 | count += 1
5 |
--------------------------------------------------------------------------------
/Thursday March 1st/code/enumerate.py:
--------------------------------------------------------------------------------
1 | attendees = ['Celestino', 'Yasha', 'Hamid']
2 |
3 | for i, attendee in enumerate(attendees):
4 | print(i, attendee)
5 |
--------------------------------------------------------------------------------
/Thursday March 1st/code/pass.py:
--------------------------------------------------------------------------------
1 | number = 0
2 |
3 | for number in range(10):
4 | number = number + 1
5 |
6 | if number == 5:
7 |
8 | pass # continue here
9 |
10 | print('Number is {}'.format(number))
11 |
12 | print('Out of loop')
13 |
--------------------------------------------------------------------------------
/Thursday March 1st/code/zip.py:
--------------------------------------------------------------------------------
1 | state_abvs = ['AK', 'AZ', 'MD']
2 | state_names = ['Alaska', 'Arizona', 'Maryland']
3 |
4 | for abv, name in zip(state_abvs, state_names):
5 | print('The abbrivation of {}, is {}.'.format(name, abv))
6 |
--------------------------------------------------------------------------------
/Thursday March 1st/lectures/advanced_loops.md:
--------------------------------------------------------------------------------
1 | # Advanced Loops
2 | We're going to dig into some advanced concepts with loops today.
3 |
4 | ## Enumerate
5 | Enumerate allows us to count when we use it with a list.
6 |
7 | ```python
8 | attendees = ['Celestino', 'Yasha', 'Hamid']
9 |
10 | for index, attendee in enumerate(attendees):
11 | print(index, attendee)
12 | ```
13 |
14 | ## Zip
15 | Zip lets us tie to lists together in a loop.
16 | ```python
17 | state_abvs = ['AK', 'AZ', 'MD']
18 | state_names = ['Alaska', 'Arizona', 'Maryland']
19 |
20 | for abv, name in zip(state_abvs, state_names):
21 | print('The abbrivation of {}, is {}.'.format(name, abv))
22 | ```
23 | ## Break
24 | Break lets you exit out of a loop that would keep running for longer. The break statement causes a program to break out of a loop.
25 |
26 | ```python
27 | number = 0
28 |
29 | for number in range(10):
30 | number = number + 1
31 |
32 | if number == 5:
33 |
34 | break # break here
35 |
36 | print('Number is {}'.format(number))
37 |
38 | print('Out of loop')
39 | ```
40 |
41 | ## Continue
42 | The continue statement gives you the option to skip over the part of a loop where an external condition is triggered, but to go on to complete the rest of the loop.
43 |
44 | ```python
45 | number = 0
46 |
47 | for number in range(10):
48 | number = number + 1
49 |
50 | if number == 5:
51 |
52 | continue # continue here
53 |
54 | print('Number is {}'.format(number))
55 |
56 | print('Out of loop')
57 | ```
58 |
59 | ## Pass
60 | When an external condition is triggered, the pass statement allows you to handle the condition without the loop being impacted in any way; all of the code will continue to be read unless a break or other statement occurs.
61 |
62 | As with the other statements, the pass statement will be within the block of code under the loop statement, typically after a conditional if statement.
63 |
64 | ```python
65 | number = 0
66 |
67 | for number in range(10):
68 | number = number + 1
69 |
70 | if number == 5:
71 |
72 | pass # continue here
73 |
74 | print('Number is {}'.format(number))
75 |
76 | print('Out of loop')
77 | ```
78 |
79 | ## +=
80 | a += b is essentially the same as a = a + b, except that:
81 |
82 | `+` always returns a newly allocated object, but += should (but doesn't have to) modify the object in-place if it's list or dict.
83 |
84 | In a = a + b, a is evaluated twice.
85 |
86 | ```python
87 | count = 0
88 | while count < 5:
89 | print(count)
90 | count += 1
91 | ```
92 |
--------------------------------------------------------------------------------
/Thursday March 1st/lectures/debuggingtalk.pptx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JessicaGarson/NYU-Intro-to-Python-Spring-2018/4c88234b61c2c4d0dfa14daa671a5a8cd9c799c0/Thursday March 1st/lectures/debuggingtalk.pptx
--------------------------------------------------------------------------------
/Thursday March 1st/lectures/review_of_python_concepts.md:
--------------------------------------------------------------------------------
1 | # Review of Python Concepts Covered
2 | We've been moving pretty quickly as a class so far. So let's take a step back and think about everything we've learned so far.
3 |
4 | ## Variables
5 | - They are containers of information
6 | - Variables are names that you can assign values to
7 | - Variables can contain numbers, strings, lists, True/False, or any type of information you want to store
8 | - Variable names can contain letters and underscores and should be descriptive (can you tell what it's used for?)
9 |
10 | ## Strings
11 | - Strings (text) can contain anything that you can type out on the keyboard
12 | - Strings are commonly used for names, phone numbers, email addresses, other addresses, URLs, and so much more!
13 | - Slicing is used to see parts of a string
14 | - String methods allow you to do special actions on strings (find, replace, count, lowercase, etc)
15 | - .format() is the string method we'll use most often.
16 |
17 | ## Integers
18 | Numbers like 1, 2, 3, 4, or 1341
19 |
20 | ## Floats
21 | Floating point numbers like 3.14, 3423.2342, 32.34
22 |
23 | ## Conditionals
24 | - Conditionals allow you to change the behavior of your program.
25 | - Program behavior is based on your variables.
26 | ```
27 | if condition:
28 | do something
29 | elif other_condition:
30 | do something else
31 | else:
32 | do another thing
33 | ```
34 |
35 | ## Functions
36 | - We can write our own functions which are bits of reusable code.
37 | - Functions a def statement that allows us to define our function, a body of our code we can write our code in it and a return value - that gives us a value to save.
38 | - Functions take in parameters/arguments. Parameters are the variables inside the function. Arguments are the value passed into the function.
39 | - Variables saved inside of a function are local to that function.
40 | - Variables that aren't inside of a function or are called global can be used throughout the entire program.
41 |
42 | ## Lists
43 | - Lists are containers that can hold multiple pieces of information.
44 | - Lists are commonly used to hold strings (ex: list of attendees’ names) or numbers (ex: number of attendees for each class)
45 | - Lists are a data structure that allows us to hold multiple values.
46 | - Lists are are created by placing items inside of [ ]
47 | - They are comma separated
48 |
49 | ## Loops
50 | - Using loops we can automate and repeat tasks in a very short amount of time.
51 | - A for loop lets you use each item one at a time, which is great for performing actions a certain number of times.
52 | - While loops are the cousins of conditionals.
53 | - While loops are repeating conditional statements. After an if statement, the program continues to execute code, but in a while loop, the program jumps back to the start of the while statement until the condition is False. Think about Jess and Hamid and the chalk.
54 |
55 | ## Activity
56 | Write down one thing you have learned so far. Share it with a partner.
57 |
--------------------------------------------------------------------------------
/Thursday March 22nd/About.md:
--------------------------------------------------------------------------------
1 | # Thursday March 22nd
2 | Today we're going to finish up introducing object oriented programming and than getting started writing tests for our code. Testing is a pretty cool implementation of OOP.
3 |
4 | [Slides are here](http://jessicagarson.com/NYU-Intro-to-Python-March-22/#/)
5 |
6 | ## Continuing with Objected Oriented Programming
7 | We will be covering the following:
8 | - Inheritance
9 | - Polymorphism
10 |
11 | ## Testing
12 | We're going to dive into testing from there. Since testing relies heavily on using classes.
13 | - What is testing?
14 | - Let's finish some tests
15 | - Let's write a simple program with the tests first.
16 |
17 | ## Games due Monday
18 | The text based games are due Monday. Can't wait to see what you build.
19 |
20 | ## Office Hours
21 | I'm available for office hours. The times I'm around are as follows:
22 | - Tomorrow from 8:30 - 9:30am and after 5:30, all day Saturday, Sunday, or Monday.
23 |
24 | Virtual seemed to work pretty well with one student so email me to schedule.
25 |
26 | ## Agenda
27 | ### 6:30 - 7:00
28 | Inheritance
29 | ### 7:00 - 7:20
30 | Polymorphism
31 | ### 7:20 - 8:00
32 | Testing
33 |
34 | ## Next class
35 | Our last class together :(
36 |
37 | We'll be starting by playing each others games. And doing a workshop with a guest speaker on APIs! Followed by some parting thoughts about what's happening next and how to continue learning. We'll likely go out for drinks after so if you have ideas on where to go shoot me an email.
38 |
39 | ## Resources on APIs
40 | - [Fall 2014 hackNY Hackathon - API 101](https://www.youtube.com/watch?v=QkWW999zfeE)
41 | - [How to Use an API in Python](https://www.codecademy.com/courses/python-intermediate-en-6zbLp/0/1)
42 |
--------------------------------------------------------------------------------
/Thursday March 22nd/activities/finsh_the_tests.md:
--------------------------------------------------------------------------------
1 | # The tests in todays example were unfinished
2 |
3 | Add in tests for the multiply and divide methods.
4 |
--------------------------------------------------------------------------------
/Thursday March 22nd/activities/pbj_time.md:
--------------------------------------------------------------------------------
1 | # Write a peanut butter jelly program using classes
2 |
3 | - What do you need to make sandwich?
4 |
5 | - How many slices of bread to you have left?
6 |
7 | - Is this easier?
8 |
--------------------------------------------------------------------------------
/Thursday March 22nd/activities/tdd.md:
--------------------------------------------------------------------------------
1 | # TDD activity
2 | The best way to learn TDD is to try out yourself.
3 |
4 | ## Step 1
5 | Should be run on the command line. Avoid using raw input. Strings and math are a good way to get started.
6 | Try to solve this problem:
7 |
8 | Write a function, calculateTip(amount, rating) which calculates how much you need to tip based on the total amount of the bill and the service.
9 |
10 | You need to consider the following ratings:
11 |
12 | Terrible: tip 0%
13 | Poor: tip 5%
14 | Good: tip 10%
15 | Great: tip 15%
16 | Excellent: tip 20%
17 |
18 | ## Step 2
19 | Figure out what the outcomes will be.
20 |
21 | ## Step 3
22 | Write the tests. Check out the resources section if you get stuck here.
23 |
24 | ## Step 4
25 | Run the tests. These should fail.
26 |
27 | ## Step 5
28 | Now write the code you will need for these tests to be successful.
29 |
30 | ## Step 6
31 | Did your tests pass? Yay skip to step 7.
32 |
33 | ## Step 7
34 | Refactor your code to make your tests pass.
35 |
36 | ## Step 8
37 | Play around. What happens if you make changes to your code? Do your tests always pass? Maybe try to make them fail.
38 |
--------------------------------------------------------------------------------
/Thursday March 22nd/code/__pycache__/math.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JessicaGarson/NYU-Intro-to-Python-Spring-2018/4c88234b61c2c4d0dfa14daa671a5a8cd9c799c0/Thursday March 22nd/code/__pycache__/math.cpython-36.pyc
--------------------------------------------------------------------------------
/Thursday March 22nd/code/inhertiance/ex_1.py:
--------------------------------------------------------------------------------
1 | class Customer(object):
2 | """A customer of ABC Bank with a checking account. Customers have the
3 | following properties:
4 |
5 | Attributes:
6 | name: A string representing the customer's name.
7 | balance: A float tracking the current balance of the customer's
8 | account.
9 | """
10 |
11 | def __init__(self, name, balance=0.0):
12 | """Return a Customer object whose name is *name* and starting
13 | balance is *balance*."""
14 | self.name = name
15 | self.balance = balance
16 |
17 | def withdraw(self, amount):
18 | """Return the balance remaining after withdrawing *amount*
19 | dollars."""
20 | if amount > self.balance:
21 | raise RuntimeError('Amount greater than available balance.')
22 | self.balance -= amount
23 | return self.balance
24 |
25 | def deposit(self, amount):
26 | """Return the balance remaining after depositing *amount*
27 | dollars."""
28 | self.balance += amount
29 | return self.balance
30 |
--------------------------------------------------------------------------------
/Thursday March 22nd/code/inhertiance/ex_2.py:
--------------------------------------------------------------------------------
1 | class Fam:
2 | def __init__(self, first_name, last_name='Garson',
3 | hair='brown', tounge_roll=True):
4 | self.first_name = first_name
5 | self.last_name = last_name
6 | self.hair = hair
7 | self.tounge_roll = tounge_roll
8 |
9 | def vacation(self):
10 | print('We go swimming on the lake every year during our vacation')
11 |
12 | def dinner(self):
13 | print('Family dinner is at 7pm every night')
14 |
15 |
16 | class Bro(Fam):
17 | pass
18 |
19 |
20 | alan = Bro('Alan')
21 | print('{} {}'.format(alan.first_name, alan.last_name))
22 | print(alan.hair)
23 | print(alan.tounge_roll)
24 | alan.vacation()
25 | alan.dinner()
26 |
--------------------------------------------------------------------------------
/Thursday March 22nd/code/inhertiance/ex_3.py:
--------------------------------------------------------------------------------
1 | class Fam:
2 | def __init__(self, first_name, last_name='Garson',
3 | hair='brown', tounge_roll=True):
4 | self.first_name = first_name
5 | self.last_name = last_name
6 | self.hair = hair
7 | self.tounge_roll = tounge_roll
8 |
9 | def vacation(self):
10 | print('We go swimming on the lake every year during our vacation')
11 |
12 | def dinner(self):
13 | print('Family dinner is at 7pm every night')
14 |
15 |
16 | class Bro(Fam):
17 |
18 | def has_kids(self):
19 | print('I have 2 children')
20 |
21 |
22 | def main():
23 | alan = Bro('Alan')
24 | print('{} {}'.format(alan.first_name, alan.last_name))
25 | print(alan.hair)
26 | print(alan.tounge_roll)
27 | alan.vacation()
28 | alan.dinner()
29 | jess = Fam('Jess')
30 | jess.vacation()
31 | alan.has_kids()
32 | # Can we run this?
33 | jess.has_kids()
34 |
35 |
36 | if __name__ == "__main__":
37 | main()
38 |
--------------------------------------------------------------------------------
/Thursday March 22nd/code/inhertiance/ex_4.py:
--------------------------------------------------------------------------------
1 | class Fam:
2 | def __init__(self, first_name, last_name='Garson',
3 | hair='brown', tounge_roll=True):
4 | self.first_name = first_name
5 | self.last_name = last_name
6 | self.hair = hair
7 | self.tounge_roll = tounge_roll
8 |
9 | def vacation(self):
10 | print('We go swimming on the lake every year during our vacation')
11 |
12 | def dinner(self):
13 | print('Family dinner is at 7pm every night')
14 |
15 |
16 | class Bro(Fam):
17 |
18 | def has_kids(self):
19 | print('I have 2 children')
20 |
21 | def dinner(self):
22 | print('Family dinner is at 6pm every night')
23 |
24 |
25 | def main():
26 | alan = Bro('Alan')
27 | print('{} {}'.format(alan.first_name, alan.last_name))
28 | print(alan.hair)
29 | print(alan.tounge_roll)
30 | alan.vacation()
31 | alan.dinner()
32 | jess = Fam('Jess')
33 | jess.vacation()
34 | alan.has_kids()
35 | jess.dinner()
36 | alan.dinner()
37 |
38 |
39 | if __name__ == "__main__":
40 | main()
41 |
--------------------------------------------------------------------------------
/Thursday March 22nd/code/inhertiance/ex_5.py:
--------------------------------------------------------------------------------
1 | class Fam:
2 | def __init__(self, first_name, last_name='Garson',
3 | hair='brown', tounge_roll=True):
4 | self.first_name = first_name
5 | self.last_name = last_name
6 | self.hair = hair
7 | self.tounge_roll = tounge_roll
8 |
9 | def vacation(self):
10 | print('We go swimming on the lake every year during our vacation')
11 |
12 | def dinner(self):
13 | print('Family dinner is at 7pm every night')
14 |
15 |
16 | class Bro(Fam):
17 | def __init__(self, city='boston'):
18 | self.city = city
19 | super().__init__(self)
20 |
21 | def has_kids(self):
22 | print('I have 2 children')
23 |
24 | def dinner(self):
25 | print('Family dinner is at 6pm every night, with his two kids')
26 |
27 |
28 | def main():
29 | kelly = Bro()
30 |
31 | # Initialize first name
32 | kelly.first_name = 'Kelly'
33 |
34 | # Use parent __init__() through super()
35 | print('{} {}'.format(kelly.first_name, kelly.last_name))
36 |
37 | # Use child __init__() override
38 | print(kelly.city)
39 |
40 | # Use parent swim() method
41 | kelly.vacation()
42 |
43 | jess = Fam('Jess')
44 | jess.vacation()
45 | jess.city()
46 |
47 |
48 | if __name__ == "__main__":
49 | main()
50 |
--------------------------------------------------------------------------------
/Thursday March 22nd/code/polymorphism/ex_1.py:
--------------------------------------------------------------------------------
1 | def times_3(a):
2 | return a * 3
3 |
4 |
5 | print(times_3(a=3))
6 | print(times_3(a='Jess'))
7 |
--------------------------------------------------------------------------------
/Thursday March 22nd/code/polymorphism/ex_2.py:
--------------------------------------------------------------------------------
1 | class Shark():
2 | def swim(self):
3 | print("The shark is swimming.")
4 |
5 | def swim_backwards(self):
6 | print("The shark cannot swim backwards, but can sink backwards.")
7 |
8 | def skeleton(self):
9 | print("The shark's skeleton is made of cartilage.")
10 |
11 |
12 | class Clownfish():
13 | def swim(self):
14 | print("The clownfish is swimming.")
15 |
16 | def swim_backwards(self):
17 | print("The clownfish can swim backwards.")
18 |
19 | def skeleton(self):
20 | print("The clownfish's skeleton is made of bone.")
21 |
22 |
23 | sammy = Shark()
24 | sammy.skeleton()
25 |
26 | casey = Clownfish()
27 | casey.skeleton()
28 |
--------------------------------------------------------------------------------
/Thursday March 22nd/code/polymorphism/ex_3.py:
--------------------------------------------------------------------------------
1 | class Shark():
2 | def swim(self):
3 | print("The shark is swimming.")
4 |
5 | def swim_backwards(self):
6 | print("The shark cannot swim backwards, but can sink backwards.")
7 |
8 | def skeleton(self):
9 | print("The shark's skeleton is made of cartilage.")
10 |
11 | def color(self):
12 | print('No color')
13 |
14 |
15 | class Clownfish():
16 | def swim(self):
17 | print("The clownfish is swimming.")
18 |
19 | def swim_backwards(self):
20 | print("The clownfish can swim backwards.")
21 |
22 | def skeleton(self):
23 | print("The clownfish's skeleton is made of bone.")
24 |
25 | def color(self):
26 | print("The clownfish is orange and white.")
27 |
28 |
29 | sammy = Shark()
30 |
31 | casey = Clownfish()
32 |
33 | for fish in (sammy, casey):
34 | fish.swim()
35 | fish.swim_backwards()
36 | fish.skeleton()
37 | fish.color()
38 |
--------------------------------------------------------------------------------
/Thursday March 22nd/code/polymorphism/ex_4.py:
--------------------------------------------------------------------------------
1 | class Shark():
2 | def swim(self):
3 | print("The shark is swimming.")
4 |
5 | def swim_backwards(self):
6 | print("The shark cannot swim backwards, but can sink backwards.")
7 |
8 | def skeleton(self):
9 | print("The shark's skeleton is made of cartilage.")
10 |
11 |
12 | class Clownfish():
13 | def swim(self):
14 | print("The clownfish is swimming.")
15 |
16 | def swim_backwards(self):
17 | print("The clownfish can swim backwards.")
18 |
19 | def skeleton(self):
20 | print("The clownfish's skeleton is made of bone.")
21 |
22 |
23 | def in_the_pacific(fish):
24 | fish.swim()
25 |
26 |
27 | sammy = Shark()
28 |
29 | casey = Clownfish()
30 |
31 | in_the_pacific(sammy)
32 | in_the_pacific(casey)
33 |
--------------------------------------------------------------------------------
/Thursday March 22nd/code/testing/__pycache__/math.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JessicaGarson/NYU-Intro-to-Python-Spring-2018/4c88234b61c2c4d0dfa14daa671a5a8cd9c799c0/Thursday March 22nd/code/testing/__pycache__/math.cpython-36.pyc
--------------------------------------------------------------------------------
/Thursday March 22nd/code/testing/my_math.py:
--------------------------------------------------------------------------------
1 | def add(a, b):
2 | return a + b
3 |
4 |
5 | def subtract(a, b):
6 | return a - b
7 |
8 |
9 | def multiply(a, b):
10 | return a * b
11 |
12 |
13 | def divide(a, b):
14 | return float(a) / b
15 |
16 |
17 | def main():
18 | print(add(a=3, b=6))
19 | print(subtract(a=5, b=2))
20 | print(multiply(a=3, b=6))
21 | print(divide(a=5, b=2))
22 |
23 |
24 | if __name__ == "__main__":
25 | main()
26 |
--------------------------------------------------------------------------------
/Thursday March 22nd/code/testing/test_my_math.py:
--------------------------------------------------------------------------------
1 | import my_math
2 | import unittest
3 |
4 |
5 | class TestAdd(unittest.TestCase):
6 | """
7 | Test the add function from the my_my_math.py program
8 | """
9 |
10 | def test_add_integers(self):
11 | """
12 | Test that the addition of two integers returns the correct total
13 | """
14 | result = my_math.add(1, 2)
15 | self.assertEqual(result, 3)
16 |
17 | def test_add_floats(self):
18 | """
19 | Test that the addition of two floats returns the correct result
20 | """
21 | result = my_math.add(10.5, 2)
22 | self.assertEqual(result, 12.5)
23 |
24 | def test_add_strings(self):
25 | """
26 | Test the addition of two strings returns the two string as one
27 | concatenated string
28 | """
29 | result = my_math.add('abc', 'def')
30 | self.assertEqual(result, 'abc def')
31 |
32 |
33 | class TestSubtract(unittest.TestCase):
34 | """
35 | Test the subtract function from the my_math.py program
36 | """
37 | def test_subtract_integers(self):
38 | result = my_math.subtract(3, 1)
39 | self.assertEqual(result, 0)
40 |
41 | def test_subtract_floats(self):
42 | result = my_math.subtract(1.0, 0.5)
43 | self.assertEqual(result, 0.5)
44 |
45 | def test_subtract_strings(self):
46 | self.assertRaises(TypeError, my_math.subtract, ("xyz", "z"))
47 |
48 | # Add a class for testing the multiply function
49 |
50 | # Add a class for testing divide function
51 |
52 |
53 | if __name__ == '__main__':
54 | unittest.main()
55 |
--------------------------------------------------------------------------------
/Thursday March 22nd/lectures/inheritance.md:
--------------------------------------------------------------------------------
1 | # Object Oriented Programming Continued
2 | On Monday we discussed the following concepts
3 | 1. Object oriented programming
4 | 2. The difference between objects and classes
5 | 3. The basic syntax of classes
6 | 4. How there can be class and instance variables.
7 |
8 | ## Let's talk through some examples
9 | ```python
10 | class Customer(object):
11 | """A customer of ABC Bank with a checking account. Customers have the
12 | following properties:
13 |
14 | Attributes:
15 | name: A string representing the customer's name.
16 | balance: A float tracking the current balance of the customer's account.
17 | """
18 |
19 | def __init__(self, name, balance=0.0):
20 | """Return a Customer object whose name is *name* and starting
21 | balance is *balance*."""
22 | self.name = name
23 | self.balance = balance
24 |
25 | def withdraw(self, amount):
26 | """Return the balance remaining after withdrawing *amount*
27 | dollars."""
28 | if amount > self.balance:
29 | raise RuntimeError('Amount greater than available balance.')
30 | self.balance -= amount
31 | return self.balance
32 |
33 | def deposit(self, amount):
34 | """Return the balance remaining after depositing *amount*
35 | dollars."""
36 | self.balance += amount
37 | return self.balance
38 | ```
39 |
40 | # Inheritance
41 | We already know this word. What does it mean in terms of biology?
42 |
43 | In programming, this isn't too far off too. Inheritance helps us organize classes into a hierarchy. Therefore classes can inherit attributes and behavior from classes above in the hierarchy.
44 |
45 | ## Parents and children
46 | One example is if we had a parent class called Parent that has class variables for last_name, height, and eye_color that the child class Child will inherit from the Parent.
47 |
48 | Child classes can also called subclasses. Because of the fact that the child is inheriting, we can reuse code which is pretty nifty.
49 |
50 | Let's walk through this example that shows us how variables are being pass down to a child class.
51 | ```python
52 | class Fam:
53 | def __init__(self, first_name, last_name='Garson',
54 | hair='brown', tounge_roll=True):
55 | self.first_name = first_name
56 | self.last_name = last_name
57 | self.hair = hair
58 | self.tounge_roll = tounge_roll
59 |
60 | def vacation(self):
61 | print('We go swimming on the lake every year during our vacation')
62 |
63 | def dinner(self):
64 | print('Family dinner is at 7pm every night')
65 |
66 |
67 | class Bro(Fam):
68 | pass
69 |
70 |
71 | alan = Bro('Alan')
72 | print('{} {}'.format(alan.first_name, alan.last_name))
73 | print(alan.hair)
74 | print(alan.tounge_roll)
75 | alan.vacation()
76 | alan.dinner()
77 | ```
78 |
79 | So what if we adapt the code to give the bro class a method. Can only the child class run that code?
80 |
81 | ```python
82 | class Fam:
83 | def __init__(self, first_name, last_name='Garson',
84 | hair='brown', tounge_roll=True):
85 | self.first_name = first_name
86 | self.last_name = last_name
87 | self.hair = hair
88 | self.tounge_roll = tounge_roll
89 |
90 | def vacation(self):
91 | print('We go swimming on the lake every year during our vacation')
92 |
93 | def dinner(self):
94 | print('Family dinner is at 7pm every night')
95 |
96 |
97 | class Bro(Fam):
98 |
99 | def has_kids(self):
100 | print('I have 2 children')
101 |
102 |
103 | def main():
104 | alan = Bro('Alan')
105 | print('{} {}'.format(alan.first_name, alan.last_name))
106 | print(alan.hair)
107 | print(alan.tounge_roll)
108 | alan.vacation()
109 | alan.dinner()
110 | jess = Fam('Jess')
111 | jess.vacation()
112 | alan.has_kids()
113 | # Can we run this?
114 | # jess.has_kids()
115 |
116 |
117 | if __name__ == "__main__":
118 | main()
119 | ```
120 |
121 | ## Overriding the parent class
122 | If we add another method called the same thing as another method in the child class we can override the parent method. Let's check this out in an example.
123 |
124 | ```python
125 | class Fam:
126 | def __init__(self, first_name, last_name='Garson',
127 | hair='brown', tounge_roll=True):
128 | self.first_name = first_name
129 | self.last_name = last_name
130 | self.hair = hair
131 | self.tounge_roll = tounge_roll
132 |
133 | def vacation(self):
134 | print('We go swimming on the lake every year during our vacation')
135 |
136 | def dinner(self):
137 | print('Family dinner is at 7pm every night')
138 |
139 |
140 | class Bro(Fam):
141 |
142 | def has_kids(self):
143 | print('I have 2 children')
144 |
145 | def dinner(self):
146 | print('Family dinner is at 6pm every night')
147 |
148 |
149 | def main():
150 | alan = Bro('Alan')
151 | print('{} {}'.format(alan.first_name, alan.last_name))
152 | print(alan.hair)
153 | print(alan.tounge_roll)
154 | alan.vacation()
155 | alan.dinner()
156 | jess = Fam('Jess')
157 | jess.vacation()
158 | alan.has_kids()
159 | jess.dinner()
160 | alan.dinner()
161 |
162 |
163 | if __name__ == "__main__":
164 | main()
165 | ```
166 | ## Super!
167 | With the super() function, you can gain access to inherited methods that have been overwritten in a class object.
168 |
169 | When we use the super() function, we are calling a parent method into a child method to make use of it. For example, we may want to override one aspect of the parent method with certain functionality, but then call the rest of the original parent method to finish the method. This is most commonly used with the `__init__` method.
170 |
171 | In a program that grades students, we may want to have a child class for Weighted_grade that inherits from the Grade parent class. In the child class Weighted_grade, we may want to override a calculate_grade() method of the parent class in order to include functionality to calculate a weighted grade, but still keep the rest of the functionality of the original class. By invoking the super() function we would be able to achieve this.
172 |
173 | Example:
174 | ```python
175 | class Fam:
176 | def __init__(self, first_name, last_name='Garson',
177 | hair='brown', tounge_roll=True):
178 | self.first_name = first_name
179 | self.last_name = last_name
180 | self.hair = hair
181 | self.tounge_roll = tounge_roll
182 |
183 | def vacation(self):
184 | print('We go swimming on the lake every year during our vacation')
185 |
186 | def dinner(self):
187 | print('Family dinner is at 7pm every night')
188 |
189 |
190 | class Bro(Fam):
191 | def __init__(self, city='boston'):
192 | self.city = city
193 | super().__init__(self)
194 |
195 | def has_kids(self):
196 | print('I have 2 children')
197 |
198 | def dinner(self):
199 | print('Family dinner is at 6pm every night, with his two kids')
200 |
201 |
202 | def main():
203 | kelly = Bro()
204 |
205 | # Initialize first name
206 | kelly.first_name = 'Kelly'
207 |
208 | # Use parent __init__() through super()
209 | print('{} {}'.format(kelly.first_name, kelly.last_name))
210 |
211 | # Use child __init__() override
212 | print(kelly.city)
213 |
214 | # Use parent swim() method
215 | kelly.vacation()
216 |
217 |
218 | if __name__ == "__main__":
219 | main()
220 | ```
221 | ## Multiple Inheritance
222 | Multiple inheritance is when a class can inherit attributes and methods from more than one parent class. This can allow programs to reduce redundancy, but it can also introduce a certain amount of complexity as well as ambiguity, so it should be done with thought to overall program design.
223 |
224 | ```python
225 | class Fam:
226 | def __init__(self, first_name, last_name='Garson',
227 | hair='brown', tounge_roll=True):
228 | self.first_name = first_name
229 | self.last_name = last_name
230 | self.hair = hair
231 | self.tounge_roll = tounge_roll
232 |
233 | def vacation(self):
234 | print('We go swimming on the lake every year during our vacation')
235 |
236 | def dinner(self):
237 | print('Family dinner is at 7pm every night')
238 |
239 |
240 | class Bro(Fam):
241 | def __init__(self, city='boston'):
242 | self.city = city
243 | super().__init__(self)
244 |
245 | def has_kids(self):
246 | print('I have 2 children')
247 |
248 | def dinner(self):
249 | print('Family dinner is at 6pm every night, with his two kids')
250 |
251 |
252 | class Cat:
253 |
254 | def community(self):
255 | print("I live with the fam.")
256 |
257 |
258 | class Dog:
259 |
260 | def protect_fam(self):
261 | print('I protect the fam')
262 |
263 |
264 | class Pets(Cat, Dog):
265 | pass
266 |
267 |
268 | def main():
269 | great_barrier = Pets()
270 | great_barrier.community()
271 | great_barrier.protect_fam()
272 |
273 |
274 | if __name__ == "__main__":
275 | main()
276 | ```
277 |
--------------------------------------------------------------------------------
/Thursday March 22nd/lectures/polymorphism.md:
--------------------------------------------------------------------------------
1 | # Polymorphism
2 | Polymorphism is simply the fact that we call the same method with different parameters and it can do different things.
3 |
4 | ## We already know this
5 | This is something we've already been doing for most of the class.
6 | ```python
7 | def times_3(a):
8 | return a * 3
9 |
10 |
11 | print(times_3(a=3))
12 | print(times_3(a='Jess'))
13 | ```
14 | This function behaves differently with strings than it does with integers.
15 |
16 | ## What does this mean for object oriented programming?
17 | For object-oriented programming in Python, this means that a particular object belonging to a particular class can be used in the same way as if it were a different object belonging to a different class.
18 |
19 | Let's create the following example and run it as we have been for a bit now:
20 | ```python
21 | class Shark():
22 | def swim(self):
23 | print("The shark is swimming.")
24 |
25 | def swim_backwards(self):
26 | print("The shark cannot swim backwards, but can sink backwards.")
27 |
28 | def skeleton(self):
29 | print("The shark's skeleton is made of cartilage.")
30 |
31 |
32 | class Clownfish():
33 | def swim(self):
34 | print("The clownfish is swimming.")
35 |
36 | def swim_backwards(self):
37 | print("The clownfish can swim backwards.")
38 |
39 | def skeleton(self):
40 | print("The clownfish's skeleton is made of bone.")
41 |
42 |
43 | sammy = Shark()
44 | sammy.skeleton()
45 |
46 | casey = Clownfish()
47 | casey.skeleton()
48 | ```
49 |
50 | ## Polymorphism with Class Methods
51 | We can use each of these different class types in the same way, we can first create a for loop that iterates through a tuple of objects. From there we can loop through without worrying which class type each object is.
52 |
53 | ```python
54 | class Shark():
55 | def swim(self):
56 | print("The shark is swimming.")
57 |
58 | def swim_backwards(self):
59 | print("The shark cannot swim backwards, but can sink backwards.")
60 |
61 | def skeleton(self):
62 | print("The shark's skeleton is made of cartilage.")
63 |
64 |
65 | class Clownfish():
66 | def swim(self):
67 | print("The clownfish is swimming.")
68 |
69 | def swim_backwards(self):
70 | print("The clownfish can swim backwards.")
71 |
72 | def skeleton(self):
73 | print("The clownfish's skeleton is made of bone.")
74 |
75 |
76 | sammy = Shark()
77 |
78 | casey = Clownfish()
79 |
80 | for fish in (sammy, casey):
81 | fish.swim()
82 | fish.swim_backwards()
83 | fish.skeleton()
84 | ```
85 |
86 | ## Polymorphism with a function
87 | We can also create a function that can take any object, allowing for polymorphism.
88 |
89 |
90 | ```python
91 | class Shark():
92 | def swim(self):
93 | print("The shark is swimming.")
94 |
95 | def swim_backwards(self):
96 | print("The shark cannot swim backwards, but can sink backwards.")
97 |
98 | def skeleton(self):
99 | print("The shark's skeleton is made of cartilage.")
100 |
101 |
102 | class Clownfish():
103 | def swim(self):
104 | print("The clownfish is swimming.")
105 |
106 | def swim_backwards(self):
107 | print("The clownfish can swim backwards.")
108 |
109 | def skeleton(self):
110 | print("The clownfish's skeleton is made of bone.")
111 |
112 |
113 | def in_the_pacific(fish):
114 | fish.swim()
115 |
116 |
117 | sammy = Shark()
118 |
119 | casey = Clownfish()
120 |
121 | in_the_pacific(sammy)
122 | in_the_pacific(casey)
123 | ```
124 |
--------------------------------------------------------------------------------
/Thursday March 22nd/lectures/testing.md:
--------------------------------------------------------------------------------
1 | # Test Driven Development
2 |
3 | ## Why test?
4 | Testing is the best way to figure out if your code works the way you think it does. It also helps you write better more reliable code. It also saves you times because testing is easy but debugging is hard. I like to think of testing as preventative debugging.
5 |
6 | ## Unit Testing
7 | So let's say we have this code:
8 |
9 | ```python
10 | import math
11 | import unittest
12 |
13 |
14 | class TestAdd(unittest.TestCase):
15 | """
16 | Test the add function from the math.py program
17 | """
18 |
19 | def test_add_integers(self):
20 | """
21 | Test that the addition of two integers returns the correct total
22 | """
23 | result = math.add(1, 2)
24 | self.assertEqual(result, 3)
25 |
26 | def test_add_floats(self):
27 | """
28 | Test that the addition of two floats returns the correct result
29 | """
30 | result = math.add(10.5, 2)
31 | self.assertEqual(result, 12.5)
32 |
33 | def test_add_strings(self):
34 | """
35 | Test the addition of two strings returns the two string as one
36 | concatenated string
37 | """
38 | result = math.add('abc', 'def')
39 | self.assertEqual(result, 'abcdef')
40 |
41 |
42 | class TestSubtract(unittest.TestCase):
43 | """
44 | Test the subtract function from the math.py program
45 | """
46 | def test_subtract_integers(self):
47 | result = math.subtract(1, 1)
48 | self.assertEqual(result, 0)
49 |
50 | def test_subtract_floats(self):
51 | result = math.subtract(1.0, 0.5)
52 | self.assertEqual(result, 0.5)
53 |
54 | def test_subtract_strings(self):
55 | self.assertRaises(TypeError, math.subtract, ("xyz", "z"))
56 |
57 | # Add a class for testing the multiply function
58 |
59 | # Add a class for testing divide function
60 |
61 |
62 | if __name__ == '__main__':
63 | unittest.main()
64 | ```
65 |
66 | ## Why places don't test
67 | It's hard. Testing often requires a culture change in an organization and it requires you to rethink the way you write code.
68 |
69 | ## Don't look at testing as paperwork that needs to get done.
70 |
71 | We know it's something we should do but don't, and it is simply an engineering task that needs to get done.
72 |
73 | ## But really everyone tests in some way
74 | Usually, the tests that are created aren't good or useable.
75 |
76 | ## Asserts
77 | - assert: base assert allowing you to write your own assertions
78 | - assertEqual(a, b): check a and b are equal
79 | - assertNotEqual(a, b): check a and b are not equal
80 | - assertIn(a, b): check that a is in the item b
81 | - assertNotIn(a, b): check that a is not in the item b
82 | - assertFalse(a): check that the value of a is False
83 | - assertTrue(a): check the value of a is True
84 | - assertIsInstance(a, TYPE): check that a is of type "TYPE"
85 | - assertRaises(ERROR, a, args): check that when a is called with args that it raises ERROR
86 |
87 | ## What makes a test good
88 | Good tests are repeatable, fast, informative, reliable, and focused.
89 |
90 | ## The . addicted
91 | Each test you pass you get a . for and folks who are super into testing often refer to themselves as . addictive.
92 |
93 | ## Your functions, they do too much
94 | Since you need to test as much as possible your functions will start to do less
95 |
96 | ## What is test driven development
97 |
98 | When you start with testing to create your programs instead of writing code and adjusting. You use the tests to drive your process.
99 |
--------------------------------------------------------------------------------
/Thursday March 8th/Lectures/git_and_github.md:
--------------------------------------------------------------------------------
1 | # Git and GitHub
2 |
3 | ## Git
4 | Did you ever wish you could go back in time. With git you can. Git is a version control tool. Git keeps track of changes across a collection of files for us. When we use Git, we can see what changes we made and seamlessly merge them with changes from our coworkers.
5 |
6 | This is a tool we are going to us daily as developers. This was why we introduced this concept on the very first day so that we already have some familiarity with the subject.
7 |
8 | ## GitHub
9 | GitHub is a social wrapper for git. This allows us to fork and make pull requests as we did in the first class. We can therefore also host our code on GitHub.
10 |
11 | ## Repositories
12 | Repositories are the central place where things are kept.
13 |
14 | ## How to create one
15 | To create a repo you can go into GitHub and click on the bit + in the right hand corner.
16 |
17 | ## Cloning
18 | Cloning allows us to bring our repository into our own environment
19 |
20 | ## Forking
21 | Forking gives us our own version of repository that we can make changes and it can live independently of each other.
22 |
23 | ## How to create a repository and add files to it
24 | 1. Create a repository in GitHub
25 | 2. Clone it into your local environment
26 | ```
27 | git clone
28 | ```
29 | You will likely be prompted to enter in your GitHub username and password. If you have 2 factor auth turned on which you should (two factor all the things), [If you are using HTTPS Git, instead of entering your password, enter a personal access token. These can be created by going to your
30 | [personal access tokens page](https://github.com/settings/tokens)
31 | 3. Open this directory in an atom and write code!
32 | ```
33 | atom .
34 | ```
35 | 4. Pull any changes
36 | ```
37 | git status
38 | git pull
39 | ```
40 | 5. When you are reached a stopping point. Add your files to the stage area.
41 | ```
42 | git status
43 | git add name_of_file.py
44 | ```
45 | If you want to commit all the files - be very careful with this you can use the following syntax
46 | ```
47 | git add .
48 | ```
49 | 6. Commit it
50 | ```
51 | git status
52 | git commit -m "descriptive commit message"
53 | ```
54 | 7. Push the changes to directory.
55 | ```
56 | git status
57 | git push
58 | ```
59 |
60 | ## Resources
61 | - [Create A Repo](https://help.github.com/articles/create-a-repo/)
62 | - [Cheatsheet](https://git.generalassemb.ly/ga-wdi-lessons/git-intro/blob/master/cheatsheet.md)
63 | - [How to undo almost anything with git](https://blog.github.com/2015-06-08-how-to-undo-almost-anything-with-git/)
64 |
--------------------------------------------------------------------------------
/Thursday March 8th/Lectures/virtualenv_pip_and_notebooks.md:
--------------------------------------------------------------------------------
1 | # Virtual Environments, PIP and Notebooks
2 |
3 | ## What is a virtual environment?
4 | We all have different computers and some of those computers carry some baggage. Virtual environments allow us to start fresh which is pretty helpful if we are starting a new project working with teams.
5 |
6 | ## pip install all the things
7 | If you don't have pip you will need to get it.
8 | ```
9 | python get-pip.py
10 | ```
11 | We will need to get this package before we can start using it.
12 | ```
13 | pip install virtualenv
14 | ```
15 |
16 | ## Let's create a virtual environment
17 | Let's play around with this environment and install some packages.
18 | ```
19 | mkdir playing_with_virtualenvs
20 | cd playing_with_virtualenvs
21 | virtualenv first_env
22 | source first_env/bin/activate
23 | pip install jupyter
24 | pip install ipython
25 | pip install numpy
26 | pip install pandas
27 | pip freeze
28 | pip freeze > requirements.txt
29 | ```
30 | For windows
31 | ```
32 | mkdir playing_with_virtualenvs
33 | cd playing_with_virtualenvs
34 | virtualenv first_env
35 | source first_env/Scripts/activate
36 | ```
37 |
38 | If you wanted to install a pre-made requirements.txt you do the following:
39 | ```
40 | pip install -r requirements.txt in
41 | ```
42 |
43 | ## ipython
44 | Let's check it out. And play around in it.
45 | ```
46 | ipython
47 | ````
48 |
49 | ## Jupyter
50 | Jupyter takes the concept to the next level by allowing an environment where you can play around in this interactive environment.
51 | ```
52 | jupyter notebook
53 | ```
54 |
55 | ## datetime example
56 | ```
57 | import datetime
58 |
59 | time = datetime.datetime.now()
60 |
61 | def greeting(time):
62 | name = 'Jess'
63 | print('Hello {}, the time is {}'.format(name, time))
64 |
65 | greeting(time=time)
66 | ```
67 |
68 | ## How to close a virtual environment
69 | ```
70 | deactivate
71 | ```
72 |
73 | ## Resources
74 | - [User guide if you are having trouble with windows](https://virtualenv.pypa.io/en/stable/userguide/)
75 | - [How to get pip](https://pip.pypa.io/en/stable/installing/)
76 |
--------------------------------------------------------------------------------
/Thursday March 8th/about.md:
--------------------------------------------------------------------------------
1 | # Thursday March 8th
2 |
3 | ## Slides
4 | Slides are [here](http://jessicagarson.com/NYU-Intro-to-Python-March-8)
5 |
6 | ## Start off by showing off your homework in small groups
7 | Make sure you discuss what data structure you used and why.
8 |
9 | ## Bringing back middle school dance rules today!
10 | Since things can get awkward with environment set up for pair programming we're going to go back to hanging with our kind.
11 |
12 | ## Some updates were made to the syllabus
13 | Just to make things have a more narrative flow.
14 |
15 | ## Agenda
16 | ### 6:30 - 6:40
17 | Homework Review
18 | ### 6:40 - 7:20
19 | GitHub
20 | Virtual Environments
21 | pip
22 | Jupyter notebooks
23 | ### 7:20 - 7:55
24 | Pair Programming
25 | ### 7:55 - 8:00
26 | Close out
27 |
28 | ## How to prep for next class
29 | For the next class we're going to have a guest speaker and we're going to learn the ins and outs of how the internet works and even start to make our own web server.
30 | - [How the internet works](https://web.stanford.edu/class/msande91si/www-spr04/readings/week1/InternetWhitepaper.htm)
31 | - [How the internet works - Django Girls](https://tutorial.djangogirls.org/en/how_the_internet_works/)
32 | - [Video on how the internet works](https://www.youtube.com/watch?v=zaH7rtqkY10)
33 | - [How internet works](http://www.rookiemag.com/2016/11/how-internet-works/)
34 | - [How servers work](https://computer.howstuffworks.com/web-server.htm)
35 |
36 | If you feel like reading a book on this subject [here is one I recommend](http://web.csulb.edu/~rlaster/docs/cecs572.pdf)
37 |
--------------------------------------------------------------------------------
/Thursday March 8th/pair_programming/pair_programming.md:
--------------------------------------------------------------------------------
1 | # Let's play around with everything we've been learning lately
2 |
3 | # Part 1
4 |
5 | ## Make a repository called Pair-Programming-March-18th and clone into it
6 | Let's first make new repository to put everything we're going to do in this session in it.
7 |
8 | ## Create a new environment
9 | Make a virtual environment
10 |
11 | ## Install Jupyter into the new environment
12 | Install jupyter into that environment
13 |
14 | ## Run a notebook
15 | Get your notebook started.
16 |
17 | ## Solve the following problem in your notebook
18 | - Create a dictionary with the name, favorite song, github handle, and twitter handle of you and your partner.
19 |
20 | - Create a loop so that you get the following output:
21 | ```
22 | Name: Name1
23 | Song: Song1
24 | GitHub: GitHub1
25 | Twitter: Twitter1
26 | Name: Name2
27 | Song: Song2
28 | GitHub: GitHub2
29 | Twitter: Twitter2
30 | ```
31 | ## Add your changes to git.
32 | You will want to add the jupyter notebook to python. Make sure you commit and push your file.
33 |
34 | # Part 2
35 | ## Syncing your fork
36 | Remember that fork we created in our first class. Let's try this again.
37 |
38 | ```
39 | git clone https://github.com/yourname/name_of_repo.git
40 | cd sample_to_be_forked
41 | git remote add upstream https://github.com/repo_creator/name_of_repo.git
42 | git fetch upstream
43 | git checkout master
44 | git merge upstream/master
45 | git push
46 | ```
47 |
48 | ## Create a Jupyter Notebook
49 | Create a notebook to solve the problem.
50 |
51 | ## Sets
52 | Create a set of students who were at last class (just make this up) and another set of students who are in this class. Create a program which tells you who came to this class but not last, last class but not this one, and who came to both classes.
53 |
54 | ## Add this your fork
55 | Add the code to your fork in today's repo under the pair_programming folder
56 |
57 | ## Submit a pull request
58 | Submit a pull request when you are done.
59 |
--------------------------------------------------------------------------------