Skip to content

Commit a533a88

Browse files
committed
Frontend Masters Python course
1 parent e62bcd3 commit a533a88

47 files changed

Lines changed: 960 additions & 9 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
MIT License
2-
3-
Copyright (c) 2019 G3Code-CS
1+
Copyright (c) 2013-2018 GitHub, Inc. and contributors
42

53
Permission is hereby granted, free of charge, to any person obtaining a copy
64
of this software and associated documentation files (the "Software"), to deal
@@ -9,13 +7,13 @@ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
97
copies of the Software, and to permit persons to whom the Software is
108
furnished to do so, subject to the following conditions:
119

12-
The above copyright notice and this permission notice shall be included in all
13-
copies or substantial portions of the Software.
10+
The above copyright notice and this permission notice shall be included in
11+
all copies or substantial portions of the Software.
1412

1513
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1614
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1715
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1816
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1917
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21-
SOFTWARE.
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19+
THE SOFTWARE.

‎README.md‎

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,15 @@
1-
# python
2-
Beginner and intermediate course to learn python
1+
# Frontend Masters - Two Day Python Workshop
2+
3+
These are the resources for Nina Zakharenko's Two Day Intro to and Intermediate Python Course
4+
5+
* [Watch Python Fundamentals on Frontend Masters](https://frontendmasters.com/courses/python/)
6+
7+
The majority of the content can be found on the course website.
8+
9+
* [Course Website - learnpython.netlify.com](https://learnpython.netlify.com)
10+
* [This Repo - git.io/python3](https://git.io/python3)
11+
* [Follow Nina on Twitter](https://twitter.com/nnja)
12+
13+
## License
14+
15+
The content of this project itself is licensed under the [Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International (CC BY-NC-ND 4.0) license](https://creativecommons.org/licenses/by-nc-nd/4.0/), and the underlying source code used to format and display that content, along with the code exercises is licensed under the [MIT license](LICENSE.md).

‎pyworkshop/.vscode/settings.json‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"python.pythonPath": "env/bin/python3"
3+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Part 1
2+
x = 42
3+
type(x)
4+
5+
y = 3 / 4
6+
type(y)
7+
8+
z = int('7')
9+
type(z)
10+
11+
a = float(5)
12+
type(a)
13+
14+
name = "Nina"
15+
type(name)
16+
17+
# Part 2
18+
rent = 480
19+
per_day = rent / 30
20+
print(per_day)
21+
22+
# Part 3
23+
print("Hello world")
24+
name = "Nina"
25+
print("My name is", name)
26+
27+
name = "Nina"
28+
print("Hello, my name is %s" % name)
29+
30+
name = "Nina"
31+
print(f"Hello, my name is {name} and I pay ${rent / 30} in rent per day")
32+
33+
# Part 4
34+
x = 42
35+
y = 3 / 4
36+
name = "Nina"
37+
type(x)
38+
type(y)
39+
type(name)
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Part 1 - Basic Functions
2+
3+
def add_numbers(x, y):
4+
return x + y
5+
6+
7+
add_numbers(1, 2)
8+
print(f"The product of 1 and 2 is {add_numbers(1, 2)}")
9+
10+
# Function Scope
11+
x = 1
12+
y = 2
13+
14+
def add_numbers(x, y):
15+
print(f"Inside the function, x = {x} and y = {y}")
16+
return x + y
17+
18+
print(f"Outside the function, x = {x} and y = {y}")
19+
print(f"The product of 5 and 6 is {add_numbers(5, 6)}")
20+
21+
# Positional vs Keyword Arguments
22+
def calculate_numbers(x, y, operation="add"):
23+
if operation == "add":
24+
return x + y
25+
elif operation == "subtract":
26+
return x - y
27+
calculate_numbers(2, 3)
28+
calculate_numbers(2, 3, "subtract")
29+
calculate_numbers(2, 3, operation="subtract")
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Remember, dictionaries don't have numerical indexes
2+
# like lists, so if you try to use an index number...
3+
# Unless 0 happens to be a key.
4+
my_dict = {"key": "value"}
5+
my_dict[0]
6+
7+
my_dict["hello"] = "world"
8+
my_dict["foo"] = "bar"
9+
my_dict
10+
my_dict["hello"]
11+
my_dict.get("hello")
12+
my_dict["baz"]
13+
"baz" in my_dict
14+
my_dict.get("baz", "boo")
15+
my_dict.keys()
16+
my_dict.values()
17+
my_dict.items()
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Part 1
2+
3+
my_list = ["h", "e", "l", "l", "o"]
4+
my_list
5+
my_list.append("!")
6+
my_list
7+
8+
# Slicing
9+
10+
len(my_list)
11+
my_list[4:6]
12+
my_list[4:]
13+
my_list[-2:]
14+
15+
# Lists - Adding to and removing
16+
17+
my_list.remove("l")
18+
my_list.insert(2, "l")
19+
del my_list[0]
20+
last_item = my_list.pop()
21+
last_item
22+
my_list[2]
23+
"!" in my_list
24+
my_list.sort(reverse=True)
25+
my_list
26+
sorted(my_list, reverse=False)
27+
my_list
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Lists are mutable
2+
my_list = [1, 2, 3]
3+
my_list[0] = 'a'
4+
my_list
5+
6+
# Dictionaries are also mutable
7+
my_dict = {"hello": "world"}
8+
my_dict["foo"] = "bar"
9+
my_dict
10+
11+
# Sets are mutable, but don't support
12+
# indexing or item assignment,
13+
# so you have to use add() and remove()
14+
my_set = {1, 2, 3}
15+
my_set[0] = 'a' # This will throw a TypeError
16+
my_set.add('a')
17+
my_set
18+
19+
# Tuples are immutable
20+
my_tuple = (1, 2, 3)
21+
my_tuple[0] = 'a' # This will throw a TypeError
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
my_set = {}
2+
type(my_set)
3+
my_set = set()
4+
my_set
5+
my_set = {1, 2, 3}
6+
my_set.add(4)
7+
my_set.remove(2)
8+
2 in my_set
9+
my_set
10+
my_set.add(3)
11+
my_set
12+
my_set
13+
my_other_set = {1, 2, 3}
14+
my_set.union(my_other_set)
15+
my_set.intersection(my_other_set)
16+
my_set.difference(my_other_set)
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Part 1
2+
3+
my_tuple = 1,
4+
my_tuple
5+
my_tuple[1] = 2
6+
7+
# Part 2 - Will Throw an Error
8+
# TypeError: 'tuple' object does not support item assignment
9+
10+
person = ('Jim', 29, 'Austin, TX')
11+
name, age, hometown = person
12+
name
13+
age
14+
hometown

0 commit comments

Comments
 (0)