fbaptiste / python-deepdive Goto Github PK
View Code? Open in Web Editor NEWPython Deep Dive Course - Accompanying Materials
License: GNU General Public License v3.0
Python Deep Dive Course - Accompanying Materials
License: GNU General Public License v3.0
The contents of /python-deepdive/Part 2/Section 04 - Iterables and Iterators/05 - Example 2 - Cyclic Iterators.ipynb
are duplicated in the last section of
/python-deepdive/Part 2/Section 04 - Iterables and Iterators/04 - Example 1 - Consuming Iterators Manually.ipynb
Sir which is better for competitive programming - Python or C++
Sir urgent help needed
Pls guide me through it
In the below notebook
https://github.com/fbaptiste/python-deepdive/blob/master/Part%201/Section%2004%20-%20Numeric%20Types/02%20-%20Integers%20-%20Operations.ipynb
It is mentioned that "int vs int in exponentiation, i.e result of 3 ** 2 always results in an int.
However this is always not true because of negative exponents ( 3 **-2).
In file Part 1/Section 02 - A Quick Refresher/07 - Classes.ipynb
, in the 2nd paragraph after Cell 1
, the word, should
is spelt as shgoudl
.
Note that using self is just a convention (although a good one, and you shgoudl use it to make your code more understandable by others), you could really call it whatever (valid) name you choose.
In the following file, /python-deepdive/Part 2/Section 05 - Project 2/01 - Project - Description.ipynb
, the line just before the code blocks begin reads,
However, the code presented is actually the solution to the current project.
In Part 2 > Section 06 - Generators > 05-Generator Expressions.ipynb
at cell number 34, the following expression is used
((i * j for j in range(start, stop + 1)) for i in range(start, stop + 1))
as an equivalent to the following expression
[[i * j for j in range(start, stop + 1)] for i in range(start, stop + 1)]
But they will not generate the same result. The first expression will result in the following functions,
def mult_list():
global start, stop
for i in range(start, stop + 1):
def inner():
global start, stop
nonlocal i
for j in range(start, stop + 1):
yield i * j
yield inner()
we can see that the inner function is a closure, and i
is the free variable. So the value of i
which will be used to create the generator, is 10, which results in the following
[10, 20, 30, 40, 50, 60, 70, 80, 90, 100]
[10, 20, 30, 40, 50, 60, 70, 80, 90, 100]
[10, 20, 30, 40, 50, 60, 70, 80, 90, 100]
[10, 20, 30, 40, 50, 60, 70, 80, 90, 100]
[10, 20, 30, 40, 50, 60, 70, 80, 90, 100]
[10, 20, 30, 40, 50, 60, 70, 80, 90, 100]
[10, 20, 30, 40, 50, 60, 70, 80, 90, 100]
[10, 20, 30, 40, 50, 60, 70, 80, 90, 100]
[10, 20, 30, 40, 50, 60, 70, 80, 90, 100]
[10, 20, 30, 40, 50, 60, 70, 80, 90, 100]
But the very first expression [[i * j for j in range(start, stop + 1)] for i in range(start, stop + 1)]
results the following
[[1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
[2, 4, 6, 8, 10, 12, 14, 16, 18, 20],
[3, 6, 9, 12, 15, 18, 21, 24, 27, 30],
[4, 8, 12, 16, 20, 24, 28, 32, 36, 40],
[5, 10, 15, 20, 25, 30, 35, 40, 45, 50],
[6, 12, 18, 24, 30, 36, 42, 48, 54, 60],
[7, 14, 21, 28, 35, 42, 49, 56, 63, 70],
[8, 16, 24, 32, 40, 48, 56, 64, 72, 80],
[9, 18, 27, 36, 45, 54, 63, 72, 81, 90],
[10, 20, 30, 40, 50, 60, 70, 80, 90, 100]]
I was wondering if there is any fix to this!!!
In file Part 1/Section 02 - A Quick Refresher/04 - The While Loop.ipynb
the word repeatg
seems to be a typo.
While Loops
The while loop is a way to repeatg a block of code as long as a specified condition is met.
while : code block ...
In the following file, /python-deepdive/Part 2/Section 06 - Generators/02 - Example - Fibonacci Sequence.ipynb
, the following line is unclear:
but we'll still run in Python's maximum recursion depth
I was going to change it to,
but we'll still run into Python's maximum recursion depth
but that still sounded a bit off. I'll let you decide.
Notebook 09 - Python's Built-In Iterables and Iterators.ipynb
in Part 2/Section 04 - Iterables and Iterators
needs to come before notebook 07 - Sorting Iterables.ipynb
. The video on sorting comes after the video on built-ins.
In the directory, /python-deepdive/Part 2/Section 08 - Iteration Tools/
,
02 - Slicing Iterables.ipynb
and
03 - Slicing Iterables.ipynb
are duplicates.
Hi Fred.
At the end of the file Part 3/Section 05 - Sets/06 - Frozen Sets.ipynb, we created a custom function for memoization replacing the lru_cache
.
The second version of it is:
We can even tweak this to effectively provide more efficient caching when the order of positional arguments is not important either:
def memoizer(fn):
cache = {}
def inner(*args, **kwargs):
key = frozenset(args) | frozenset(kwargs.items())
if key in cache:
return cache[key]
else:
result = fn(*args, **kwargs)
cache[key] = result
return result
return inner
@memoizer
def adder(*args):
print('calculating...')
return sum(args)
I just wanted to note that this cache mechanism won't work if we have duplicate arguments. That set (frozenset actually) removes the duplicate arguments.
Take a look at this example:
print(adder(1, 2, 2))
print(adder(1, 1, 2)) # 5 !!
You may add a note that arguments should be different for this to work.
Thanks.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.